PDA

View Full Version : Is there such a script?



joycie
07-07-2006, 01:37 PM
I have tried to look for such a script but to no avail. Can someone help?

Details:
When I click on "Content A", the cursor will automatically move to "Content A with the subcontent" way below the webpage. After browsing, I click on the <back to top> to bring the cursor back to the top.

1) Content A
2) Content B
3) Content C

<back to top>
1) Content A
Subcontent........

<back to top>
2) Content B
Subcontent........

<back to top>
3) Content C
Subcontent........

jr_yeo
07-07-2006, 03:30 PM
<A href="#content_a">Content A</A>

// somewhere else on the html

<a name="content_a"></a>
1) Content A
Subcontent.......


hope u got the idea... :)

joycie
07-09-2006, 03:59 AM
Thank you but this doesn't seem to work.

jscheuer1
07-09-2006, 04:18 AM
Well, that won't actually move the cursor, only the page, and only if there is page to move to get to the named anchor. However, if you only want to jump to a certain spot on the page, this is the way to go. If you need to actually move the cursor, you will need to use a form element like a textarea or text input and give it focus. There should be no need for this though, unless content A is already a form.

For a more involved discussion of how named anchors work, see:

http://www.w3schools.com/html/html_links.asp

scroll down the page to 'The Anchor Tag and the Name Attribute'. Although the example given is for a .asp page, this same technique also works on regular .htm and .html pages. It's biggest advantage is that no javascript is required.

joycie
07-09-2006, 06:32 AM
Thank you, John. That answers my question.:D