var jump=function(e)
{
offsetH = 90;
if ($(window).width() < 768) {
offsetH = $('header').innerHeight();
}
if (e){
e.preventDefault();
var target = $(this).attr("href");
}else{
var target = location.hash;
}
console.log(target);
$('html,body').animate(
{
scrollTop: $(target).offset().top - offsetH
},2000,function()
{
location.hash = target;
});
}
$('html, body').hide();
$(window).load(function()
{
// $('a[href^="#"]').trigger("click", jump);
if (location.hash){
setTimeout(function(){
// console.log(location.hash );
$('nav ul li a,.side_bar ul li a[href^="'+ location.hash +'"]').trigger("click");
$('html, body').scrollTop(0).show();
jump();
}, 0);
}else{
$('html, body').show();
}
});
No comments:
Post a Comment