smooth scrolling to anchor (#)

Soldato
Joined
19 Oct 2002
Posts
3,480
Hi guys,

i was wondering if anyone knows the JS to make a windows scroll smoothly to an anchor destination?

i thought window.ScrollTo(x,y) was smooth but it just jumps...

the effect i'm after is used here http://jquery.com/demo/thickbox/ - click on one of the links at the top... funky effect i just want to get some minimal slick code to do it... could anyone give me a leg up?
 
download it and look at the source? but what's the point of writing your own? the whole point of that is so you can implement it on your own site with minimum effort. :)
 
marc2003 said:
download it and look at the source? but what's the point of writing your own? the whole point of that is so you can implement it on your own site with minimum effort. :)
that is just an effect on the page, it is not the topic of the site (thickbox) - i looked at the code but there was loads of javascript and i'm not good enough at it to decipher which bits i need...
 
oops. :o how about the main jquery homepage. seems odd using an effect like that if it's not part of the code you can download? :)
 
Download this file, and put it in the same directory as the page you want to add the effect to.

Then in the page header put:
Code:
<script language="text/javascript" src="smoothscroll.js">
Smooth scroll script
</script>

It will automatically parse all links on the page & sort internals from externals, and give the smooth scroll effect to the internal anchors ;)

Jon

PS. The code is all commented, so if you want to look through it, there are a lot of meaningful and helpful comments :)
 
Last edited:
QuiKsiLVeR said:
dood... the scolling is nothing to do with the thickbox, just a funky effect the designer of that page decided to implement...

eh? did i mention thickbox? i said look at the main jquery.com page. :p

anyway it looks like you have an answer. :)
 
Back
Top Bottom