简体   繁体   English

如何防止iOS webapp中的链接在新的Safari选项卡中打开

[英]How to prevent links in iOS webapp from opening in a new Safari-tab

I'm creating an html application for iPads. 我正在为iPad创建一个html应用程序。 I add the webapp to the homescreen using the "favorite" option. 我使用“收藏夹”选项将webapp添加到主屏幕。 However, after I do this, every (internal) URL opens in a new safari tab. 但是,执行此操作后,每个(内部)URL都会在新的Safari选项卡中打开。 How do I prevent this? 我该如何防止这种情况? At the moment it is impossible to use my navigation which directs to other html files. 目前无法使用导航到其他html文件的导航。

I aready found this code. 我找到了这段代码。 Hower i get an error "undefined" on every url. 我在每个网址上都收到错误“未定义”。

$( document ).on( "click", "a", function( event ){   
    page.event.preventDefault();   
    time.location.href = $( event.target ).attr( "href" );
});

You are using a page and time variables, which don't seem to be defined anywhere. 您正在使用pagetime变量,这些变量似乎没有在任何地方定义。

$(document).on('click', 'a', function(e) {
    e.preventDefault();
    document.location.href = $(this).attr('href');
});

As simple as that. 就如此容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM