Chrome中的锚点标记无法正常工作?这是一个铬错误吗? [英] Anchor Tag in chrome not working properly?Is this a chrome Bug?
本文介绍了Chrome中的锚点标记无法正常工作?这是一个铬错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个网站 http://rethinkwaste.com.au/ 。当点击第一张幻灯片时,我设置了一个锚点
I have a site http://rethinkwaste.com.au/ . When clicking on the very first slide I have a anchor set up
<div id="illegal"></div>
在谷歌浏览器中第一次加载时,这似乎跳回到页面顶部。这是一个铬错误?
On the first load out in google chrome this seems to jump back up to the top of the page. Is this a chrome bug?
如果我然后刷新或从滑块链接加载页面,它似乎工作正常。
If I then refresh or load page from slider link it seems to work ok.
推荐答案
我认为它是 Chrome bug 。因此,经过一些搜索,我发现这个解决方案。
I think its a Chrome bug. So After some searching i found this solution.
jQuery(window).load(function(){
var hashNum = 0;
if (window.location.hash != ''){
hashNum = window.location.hash.replace("#illegal", "");
console.log('hashNum: ' + hashNum);
};
hashMenu = jQuery("#illegal").offset().top;
jQuery('html,body').animate({
scrollTop: hashMenu
}, 1000);
});
这篇关于Chrome中的锚点标记无法正常工作?这是一个铬错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文