Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Scrolling to an internal Link

Reply
Thread Tools

Scrolling to an internal Link

 
 
Iain Adams
Guest
Posts: n/a
 
      06-18-2007
Hello,

I have a page with a text field. When something is typed into the text
field and a button is clicked I want the page to scroll to the
relevant place on the page that has the value of the text field as its
name.

i.e

A piece of information

<span name="gohere">
hello world
</span>

I then have an input field and a button. If "gohere" is entered and
the button clicked I want the page to scroll to the span above (like
an internal link) Is this possible??

 
Reply With Quote
 
 
 
 
-Lost
Guest
Posts: n/a
 
      06-18-2007
Iain Adams wrote:
> Hello,
>
> I have a page with a text field. When something is typed into the text
> field and a button is clicked I want the page to scroll to the
> relevant place on the page that has the value of the text field as its
> name.
>
> i.e
>
> A piece of information
>
> <span name="gohere">
> hello world
> </span>
>
> I then have an input field and a button. If "gohere" is entered and
> the button clicked I want the page to scroll to the span above (like
> an internal link) Is this possible??


Hrmm... probably yes. However, wouldn't using named anchors be much
more suitable?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
 
Reply With Quote
 
 
 
 
Iain Adams
Guest
Posts: n/a
 
      06-18-2007
On 18 Jun, 14:26, -Lost <(E-Mail Removed)> wrote:
> Iain Adams wrote:
> > Hello,

>
> > I have a page with a text field. When something is typed into the text
> > field and a button is clicked I want the page to scroll to the
> > relevant place on the page that has the value of the text field as its
> > name.

>
> > i.e

>
> > A piece of information

>
> > <span name="gohere">
> > hello world
> > </span>

>
> > I then have an input field and a button. If "gohere" is entered and
> > the button clicked I want the page to scroll to the span above (like
> > an internal link) Is this possible??

>
> Hrmm... probably yes. However, wouldn't using named anchors be much
> more suitable?
>
> --
> -Lost
> Remove the extra words to reply by e-mail. Don't e-mail me. I am
> kidding. No I am not.


Well yeah named anchors would be good. But Say I have thousands of
places I want to jump to. Then I wud have to have thousands of links.
<a href="#gohere">. This probaly wouldnt be much good. What i want is
a named anchor but without the actual anchor. haha. Basically i want
to replicate what the named anchor does but when a button is clicked
and using the name given in a text field. Do you know how to do this?

 
Reply With Quote
 
kaaposc
Guest
Posts: n/a
 
      06-18-2007
Iain Adams wrote:
> On 18 Jun, 14:26, -Lost <(E-Mail Removed)> wrote:
>> Iain Adams wrote:
>>> Hello,
>>> I have a page with a text field. When something is typed into the text
>>> field and a button is clicked I want the page to scroll to the
>>> relevant place on the page that has the value of the text field as its
>>> name.
>>> i.e
>>> A piece of information
>>> <span name="gohere">
>>> hello world
>>> </span>
>>> I then have an input field and a button. If "gohere" is entered and
>>> the button clicked I want the page to scroll to the span above (like
>>> an internal link) Is this possible??

>> Hrmm... probably yes. However, wouldn't using named anchors be much
>> more suitable?
>>
>> --
>> -Lost
>> Remove the extra words to reply by e-mail. Don't e-mail me. I am
>> kidding. No I am not.

>
> Well yeah named anchors would be good. But Say I have thousands of
> places I want to jump to. Then I wud have to have thousands of links.
> <a href="#gohere">. This probaly wouldnt be much good. What i want is
> a named anchor but without the actual anchor. haha. Basically i want
> to replicate what the named anchor does but when a button is clicked
> and using the name given in a text field. Do you know how to do this?
>


what about the same old named anchors and button with
onclick="location.href='#'+document.getElementById ('text_field').value" ?

see, if you want to scroll page to some span you first need to find that
span according to what user typed in text field, then you need to
calculate offset of that span and then scroll there (something like
"document.scrollTop=there", not sure if correct syntax, check it out).
 
Reply With Quote
 
scripts.contact
Guest
Posts: n/a
 
      06-18-2007
On Jun 18, 5:19 am, Iain Adams <(E-Mail Removed)> wrote:
> Hello,
>
> I have a page with a text field. When something is typed into the text
> field and a button is clicked I want the page to scroll to the
> relevant place on the page that has the value of the text field as its
> name.



var elem=document.getElementsByName(textFieldValue)
if(elem)elem.scrollIntoView()

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
smooth scrolling & auto scrolling sillyputty Firefox 1 08-24-2007 02:10 AM
internal link/jump within div that has vertical scrolling stan@capitalcityrealty.ca Javascript 0 12-25-2006 08:52 PM
RE: Link Link Link =?Utf-8?B?REw=?= Windows 64bit 0 05-17-2005 12:15 PM
Re: Link Link Link DANGER WILL ROBINSON!!! Kevin Spencer ASP .Net 0 05-17-2005 10:41 AM
internal to internal NAT? Mike Cisco 1 04-21-2004 12:15 PM



Advertisments