Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery选项卡避免锚从外部链接跳转_Jquery_Url_Tabs_Anchor - Fatal编程技术网

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

我的页面上有一个Jquery选项卡,我想防止当访问者从包含url(www.mypage.html#myanchor)中锚定的外部链接访问页面时,页面将跳转到实际锚定。我只想选择选项卡,而不是跳转。 我仍然是jquery的新手,以下是我用于构建选项卡的代码:

 <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);
}