ok, now that the smooth scrolling has Klaus's blessing :) ... I
thought I'd share some code I wrote to make it happen for all same-
page links. It takes into account the difference in the way the
various browsers treat href.
Oh yeah, now that Brandon has fixed that for .attr('href') in the
latest SVN, the code could be shortened a great deal. Unfortunately,
I don't have time just now to do that, so here is the old code, which
won't break anything with latest SVN, and will also make things work
in older jQuery versions (the Interface ScrollTo plugin is required):
var docHashIndex = location.href.indexOf("#");
if (docHashIndex != -1) {
var docURL = location.href.slice(0,docHashIndex);
}
else {
var docURL = location.href;
}
$('[EMAIL PROTECTED]"#"]').click(function() {
var $linkHref = $(this).href();
var linkHashIndex = $linkHref.indexOf('#');
var linkURL = $linkHref.slice(0,linkHashIndex);
var linkHash = $linkHref.slice(linkHashIndex);
if (docURL == linkURL) {
if ($(linkHash).length > 0 ) {
$(linkHash).ScrollTo(400);
return false;
} else {
$linkDest = $("[EMAIL PROTECTED]" + linkHash.slice(1) +']');
if ($linkDest.length > 0) {
$linkDest.ScrollTo(400);
return false;
}
}
}
});
Hope that's helpful to someone.
Cheers,
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/