简体   繁体   中英

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. Therefore each link I tap inside the web App is being opened in mobile Safari.

I tried this Script which seemed to be a good way to prevent links to be opened in Safari. However this won't work in iOS 9 anymore.

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. And yes, it even works in 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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