Scrolling div's and anchor links

Posted by Rob CornishPostMarch 24, 2008Date

I've just hit a browser difference that stopped me for a while!

My problem:

Text links outside a scolling div to jump the scroll view to the desired location within the scrolling div.
The scrolling div has the css overflow:auto; with a set height to enable scrolling.
Using normal anchor links and names worked for firefox but not IE6 + IE7, after researching on the net I came across a javascript equivalent.

document.getElementById('elmID').scrollIntoView(true);

This is how I used the code, by adding this line of code into the anchor tag:

<a href="javascript:document.getElementById('elmID').scrollIntoView(true);">

Using this javascript and adding ID's to the areas I needed for scroll view worked a treat!


3 Comments »

  1. awesome - thanks!

    Comment by dan — July 10, 2008 @ 1:46 am

  2. How would you implement this method for text links on a different page to navigate to the scrolling div page then jump the scroll view to the desired location within the scrolling div?

    Regards

    Comment by james — August 20, 2009 @ 8:36 am

  3. Great code, it works, thanks!!

    Comment by Carlo Politi — October 14, 2009 @ 10:47 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Tags
Flickr
DSC_0207DSC_0206DSC_0205DSC_0197
© 2008 dlnqnt - Admin - Login