简体   繁体   English

如何防止iPhone Web App链接在Safari中打开?

[英]How to prevent iPhone web app links from opening in Safari?

I have a web app that I contains links to several pages. 我有一个网络应用程序,其中包含指向多个页面的链接。 I am using jQuery Mobile framework. 我正在使用jQuery Mobile框架。 However, when I click a link, it opens the page in Safari and not in the web app. 但是,当我单击链接时,它将在Safari中而不是在Web应用程序中打开页面。

Here is my javascript code that I link to in the page with the links: 这是我在页面中使用链接链接到的JavaScript代码:

$( document ).on (
"click",
"a",
function( event ) {
    event.preventDefault();

    location.href = $( event.target ).attr ( "href" );
}
);

Is it outdated now or am I missing something? 现在过时了还是我错过了什么?

$(document).delegate("a", "vclick click", function(event) {
  $.mobile.defaultPageTransition = "slide";                
   var href = $(this).attr("href");
   event.preventDefault();
   if ( event === "click" ) { return; }                      
   $.mobile.changePage(href);
});

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

相关问题 防止独立 Web 应用程序中的链接在 Rails 上使用模式打开 Mobile Safari - Prevent links in standalone web apps opening Mobile Safari with modals on rails 如何防止应用浏览器中的Facebook打开我的网站链接? - How to prevent Facebook in app browser from opening my website links? 如何防止iOS webapp中的链接在新的Safari选项卡中打开 - How to prevent links in iOS webapp from opening in a new Safari-tab iOS 9 Web应用阻止链接在移动Safari中打开 - iOS 9 web app prevent links to open in mobile safari 如何防止iframe打开新链接? - How to prevent iframe from opening new links? 当您从 Chrome 访问时,如何防止 PWA 应用打开 target="_blank" 链接? - How to prevent target="_blank" links from opening by PWA app while you visit from chrome? 如何防止 iframe 中的链接在新标签页中打开 - How to prevent links in iframe from opening in new tab 如何防止iframe中的链接在新窗口中打开? - How can I prevent links in iframes from opening in new window? 使用javascript:history.go(-1)时,iPhone Safari Web App在新窗口中打开链接 - iPhone Safari Web App opens links in new window when using javascript:history.go(-1) 从iPhone上的全屏网络应用程序启动移动Safari - Launch mobile safari from full screen web app on iPhone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM