简体   繁体   English

iOS 9 Web应用阻止链接在移动Safari中打开

[英]iOS 9 web app prevent links to open in mobile safari

I know this is a known issue but since iOS 9 it seems that links can't be opened within an web App anymore. 我知道这是一个已知问题,但是自iOS 9以来,似乎无法再在Web App中打开链接。 Therefore each link I tap inside the web App is being opened in mobile Safari. 因此,我在Web App中点击的每个链接都在移动Safari中打开。

I tried this Script which seemed to be a good way to prevent links to be opened in Safari. 我尝试了此脚本 ,这似乎是阻止在Safari中打开链接的好方法。 However this won't work in iOS 9 anymore. 但是,这将不再适用于iOS 9。

So my question is: Does anyone know a working alternative for this issue? 所以我的问题是:有人知道这个问题的可行替代方案吗?

So apparently you can prevent links to open in Safari if you put this script before the closing </body> tag. 因此,显然,如果将此脚本放在</body>标记之前,则可以防止在Safari中打开链接。 And yes, it even works in iOS 9. 是的,它甚至可以在iOS 9中使用。

<script type="text/javascript">
    var a=document.getElementsByTagName("a");
    for(var i=0;i<a.length;i++)
    {
       a[i].onclick=function()
       {
           window.location=this.getAttribute("href");
           return false
       }
    }
</script>

暂无
暂无

声明:本站的技术帖子网页,遵循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 如何防止iPhone Web App链接在Safari中打开? - How to prevent iPhone web app links from opening in Safari? 使用javascript从Web应用程序强制链接在移动Safari中打开 - Force link to open in mobile safari from a web app with javascript 在iOS 8中打开从Web应用程序到新Safari窗口的链接 - Open a link from web app to new Safari window in iOS 8 如何在移动Web应用程序上禁用切换横向/纵向(Android Browser / iOS-Mobile Safari) - How to disable toggling of landscape/portrait on a mobile web app (Android Browser/iOS-Mobile Safari) iOS-如何在默认浏览器(Safari或Chrome)而非应用内浏览器中打开链接? - iOS - How to open the links in the default browser (Safari or Chrome) instead of the in-app browser? 尝试打开未安装的本机应用程序时如何防止 iOS Safari 警报? - how to prevent iOS safari alert when trying to open non-installed native app? ios PWA 如何在移动默认 safari 上打开外部链接(不在应用浏览器中) - ios PWA How to open external link on mobile default safari(not In app browser) window.open()在添加到主屏幕的移动Safari Web应用程序中不起作用 - window.open() doesn't work in mobile Safari web-app added to home screen 链接在Mobile Safari上不起作用 - Links not working on Mobile Safari
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM