Hi.
I was looking for a script to implement an anchor link to a different url with a smooth scroll effect.
I have tested different solutions and I like the script here
The example here
It works fine, but the problem is that I have a second listing of links in page2, pointing at anchors also in the same page2, and then the smooth effect does not work since you are not linking to a third page but to an anchor in the same one.
The script:
(function($){
var jump=function(e)
{
if (e){
e.preventDefault();
var target = $(this).attr("href");
}else{
var target = location.hash;
}
$('html,body').animate(
{
scrollTop: $(target).offset().top
},1000,function()
{
location.hash = target;
});
}
$('html, body').hide()
$(document).ready(function()
{
$('a[href^=#]').bind("click", jump);
if (location.hash){
setTimeout(function(){
$('html, body').scrollTop(0).show()
jump()
}, 0);
}else{
$('html, body').show()
}
});
})(jQuery)
Is it possible to modify this script to get the same effect when linking to the same page? Or am I wasting my time with it?
Thanks very much.