SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2001
    New Orleans
    0 Post(s)
    0 Thread(s)

    trying to get link to not go to the top


    I'm trying to create a contact page in javascript that will list the phone numbers and other contact information of each individual of the company when clicked. I read up on javascript and through some simple additions to other scripts, i've made mine work how I want.

    Except for one thing.

    Since my javascript is using an onclick function, I set the href as '#' as most people would do. The problem is that, say, a member of the company would be far down along the page, requiring the user to scroll down. If the user was to click on this person, the page would reload, going all the way back to the top, forcing the user to scroll down again to get the information he/she wanted.

    What I want to know is if there is a way that when a user clicks on a link so that it doesn't have to scroll all the way back up to the top of the page like that, but to remain where it is.

    Anyone know anything about this?

    EDIT: NM, I am just stupid. I just used a <span> tag instead of linking it. Duh....
    Last edited by Joseph Ellis; Jul 30, 2003 at 09:53.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Dallas, TX
    0 Post(s)
    0 Thread(s)
    OR, you could be much more compliant, accessible, and user-friendly and do it this way

    <a href="somepage.htm" onlick=";return false;">Link</a>

    Never, EVER, use "#" for a link unless you want it to be a top-anchor. It literally means "page top" and will scroll to the top of the current page.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev


Posting Permissions

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