HunterBeckham Posted March 15, 2015 Share Posted March 15, 2015 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 [webclip] 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted March 16, 2015 Share Posted March 16, 2015 Do you have an unpacked version of that code? Link to comment Share on other sites More sharing options...
HunterBeckham Posted March 17, 2015 Author Share Posted March 17, 2015 Do you have an unpacked version of that code? no Link to comment Share on other sites More sharing options...
justsomeguy Posted March 17, 2015 Share Posted March 17, 2015 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? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now