Yanlu
Yanlu

Reputation: 335

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?

Upvotes: 0

Views: 1736

Answers (1)

Yanlu
Yanlu

Reputation: 335

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>

Upvotes: 1

Related Questions