I have four links with href's pointing to URLs of pages that are loaded via .load()
, the problem is in IE the page jumps when you click it, i have attached a (window).scrollTo(0)
to the code and fixes it in all browsers besides IE.
I also have return false
on the code so it stops the default behaviour.
I have seen: Page jumps to the top onclick and tried implementing the answers but it just doesn't seem to work for me.
Does anyone know a solution ?
the href's:
<a href="welcome.html" name="welcome">Welcome</a>
<a href="about.html" name="about">About</a>
<a href="forum.html" name="forum">Forum</a>
<a href="contact.html" name="contact">Contact</a>
jQuery Code:
$('#jqNav li a').click(function(e){
if($(this).parent().is(".nav1")){ $('.landing .main .nav ul').css({ "background-position" : "0 -50px" });}
else if($(this).parent().is(".nav2")) { $('.landing .main .nav ul').css({ "background-position" : "0 -100px" });}
else if($(this).parent().is(".nav3")) { $('.landing .main .nav ul').css({ "background-position" : "0 -150px" });}
else if($(this).parent().is(".nav4")) { $('.landing .main .nav ul').css({ "background-position" : "0 -200px" });};
stopAnim = true;
$page = $(this).attr('href');
var $hashTag = $(this).attr('name');
window.location.hash = $hashTag;
loadData();
$(window).scrollTop(0);
e.preventDefault();
});