Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: Onclick

  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Onclick

    Hello all

    I have a small issue...i have lots of text(different sections) on the same page...if the user clicks on the menu whcih is on the left hand side, it should point(take) to the appropriate section text...i wondering how to do that

    Any help???

  • #2
    Regular Coder BoldUlysses's Avatar
    Join Date
    Jan 2008
    Location
    Winston-Salem, NC
    Posts
    938
    Thanks
    10
    Thanked 190 Times in 187 Posts
    Sounds like you're interested in an anchor. You use the <a> tags, but point the link inside the page rather than to an external file:

    http://www.w3schools.com/tags/tryit...._link_bookmark

    In the example,

    Code:
    <a href="#C4">See also Chapter 4</a>
    points to this:

    Code:
    <a name="C4">Chapter 4</a>
    within the page.
    matt | design | blog

  • #3
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    its call an "anchor" tag

    this would be the link
    Code:
    <a href="#tips">Jump to the Useful Tips Section</a>
    this is where it would jump to
    Code:
    <a name="tips">Useful Tips Section</a>

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Set a named anchor like
    Code:
    <a href="#section1">section 1</a>
    <a href="#section2">section 2</a>
    <a href="#section3">section 3</a>
    for each of your sections like
    Code:
    <div id="section1">section 1 content</div>
    <div id="section2">section 2 content</div>
    ....
    You can set such anchors to any element, having some id

    Edit: Late .. though latest see http://www.w3.org/TR/xhtml1/#h-4.10
    Last edited by abduraooft; 07-18-2008 at 05:20 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Jun 2008
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks guys....its solved...much appreciated

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,928
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    Yes, to emphasize: Don’t use the name attribute! Except on form elements this attribute is deprecated and should not be used anymore. ID has the same effect along with many more possibilities.

  • #7
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    While "name" works (per the link provided in the thread), I understand that "id" is a better linking object.
    .
    .
    ...and gladly would he learn and gladly teach

    Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls


  •  

    Posting Permissions

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