[英]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.