Web Analytics Made Easy -
StatCounter changing "display" scrolls to top - CodingForum

Announcement

Collapse
No announcement yet.

changing "display" scrolls to top

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • changing "display" scrolls to top

    I've implemented a collapsable menu using javascript and css, using a function triggered by an onclick event to toggle the "display" property of a div between block and none .

    The menu itself functions as I expected it to, however when a user clicks on a menu in order to expand or collapse it, the web browser also scrolls up to the top of the page. I've noticed the behavior on both IE6 and on Firefox 1.0.6.

    Is there an option somewhere that can be set to prevent this from happening? The alternative (I think) would be to add a call in the toggle function to return the frame to it's previous position, but I assume this would give the page a jerky feel, which is obviously undesirable...

    Thanks,
    Ken

  • #2
    in the onclick add ;return false after the function
    Code:
    <a href="#" onclick="doSomething()[b];return false[/b]">Go</a>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      Sorry for the delayed reply; unfortunately the way things are set up at work it's difficult for me to get in from home..

      In any case, that seems to be all it took; thank you.

      Ken

      Comment

      Working...
      X