Jump to content

Recommended Posts

I Am Creating A iOS WebApp [ StandAlone] Which Looks Like A iOS Application The Only Difference That It Written In HtmlAnd JavascriptWhen You Go To A Website and click on add to home screen it creates an icon with the site content


i have created a website and i need help with one little detail

i found that script in my site it permit all links to open in the webapp

i was trying to make the links open in safari but when i manage to do that, the navigation menu doesn't work

could any one help me please ?heres the code

Detect if iOS WebApp Engaged and permit navigation without deploying Safari

(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")
i need to open the links in safari rather than the webapp thats it :D

Share this post

Link to post
Share on other sites

Here's what the code does:

if ("standalone" in window.navigator && window.navigator["standalone"]) {    var node,         re = /^(a|html)$/i;    document.addEventListener("click", function (event) {        node = event.target;        while (!re.test(node.nodeName)) node = node.parentNode;        "href" in node && (node.href.indexOf("http") || ~node.href.indexOf(document.location.host)) && (event.preventDefault(), document.location.href = node.href)    }, false)}
It looks like it is checking for an anchor element with an external link and use document.location.href to redirect the current page. How are you supposed to use Javascript to open Safari in iOS? Will it work if you use window.open?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...