Results 1 to 5 of 5

Thread: Is there such a script?

  1. #1
    Join Date
    Jul 2006
    Posts
    95
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Default Is there such a script?

    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........

  2. #2
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    HTML Code:
    <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...

  3. #3
    Join Date
    Jul 2006
    Posts
    95
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Default

    Thank you but this doesn't seem to work.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2006
    Posts
    95
    Thanks
    21
    Thanked 0 Times in 0 Posts

    Default

    Thank you, John. That answers my question.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •