jquery选项卡避免锚从外部链接跳转
我的页面上有一个Jquery选项卡,我想防止当访问者从包含url(www.mypage.html#myanchor)中锚定的外部链接访问页面时,页面将跳转到实际锚定。我只想选择选项卡,而不是跳转。 我仍然是jquery的新手,以下是我用于构建选项卡的代码:jquery选项卡避免锚从外部链接跳转,jquery,url,tabs,anchor,Jquery,Url,Tabs,Anchor,我的页面上有一个Jquery选项卡,我想防止当访问者从包含url(www.mypage.html#myanchor)中锚定的外部链接访问页面时,页面将跳转到实际锚定。我只想选择选项卡,而不是跳转。 我仍然是jquery的新手,以下是我用于构建选项卡的代码: <script> $(function() { $( "#tabs" ).tabs({ select: function(event, ui) { // loading
<script>
$(function() {
$( "#tabs" ).tabs({
select: function(event, ui) {
// loading an iframe src on select
if (ui.index==2){
go('iframes/tendaggi_ignifughi.html');
}
}
});
});
</script>
$(函数(){
$(“#制表符”)。制表符({
选择:功能(事件、用户界面){
//在select上加载iframe src
如果(ui.index==2){
go('iframes/tendaggi_ignifughi.html');
}
}
});
});
如果您能回答我应该如何修改上述代码以实现我的需求,我们将不胜感激。请尝试以下代码:
if (location.hash) { // do the test straight away
window.scrollTo(0, 0); // execute it straight away
setTimeout(function() {
window.scrollTo(0, 0); // run it a bit later also for browser compatibility
}, 1);
}