iPhone Safari Web App opens links in new window

iPhone Safari Web App opens links in new window

In this Post We Will Explain About is iPhone Safari Web App opens links in new window With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to iPhone Safari Web App opens links in new windowExample

In this post we will show you Best way to implement apple-mobile-web-app-capable open link in safari, hear for Open PDF in new window from iphone home screen web appwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Example : iPad Web App links opening in Safari

<script type="text/javascript">
var mywebkit;
if (!mywebkit) {
    mywebkit = window.onload = function() {
        function allfullscreen() {
            var a = document.getElementsByTagName("a");
            for (var i = 0; i < a.length; i++) {
                if (a[i].className.match("noeffect")) {} else {
                    a[i].onclick = function() {
                        window.location = this.getAttribute("href");
                        return false
                    }
                }
            }
        }

        function sihideURLbar() {
            window.scrollTo(0, 0.9)
        }
        mywebkit.liveinit = function() {
            allfullscreen();
            sihideURLbar()
        };
        mywebkit.liveinit()
    }
}
</script>

Example 1: Header Settings

<!-- simple Settings for Stand-alone settings for iOS. -->
<meta name="apple-mobile-web-app-capable" content="yes" />
//set header in html DOM
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
//set header in html DOM
<meta name="apple-mobile-web-app-status-bar-style" content="black" />

Example 2: JavaScript solution in iWebKit framework

var alive=document.getElementsByTagName("a");
//using Loopings
for(var sdata=0;sdata<alive.length;sdata++)
{
    alive[sdata].onclick=function()
    {
        window.location=this.getAttribute("href");
		//simple return
        return false;
    }
}

Example 3: iPhone Safari Web App opens links in new window

<script>
//set simple javascript
    (function(a, b, c) {
		//check conditions
        if (c in b && b[c]) {
			//simple varibles declare
            var d, e = a.location,
                f = /^(a|html)$/i;
				//simple function call
            a.addEventListener("click", function(a) {
                d = a.target;
				//check conditions and while loop
                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")
	</script>

Example

Read Also:  bootstrap set active tab javascript - How to change active bootstrap tab with javascript?

I hope you have Got What is How to Prevent iOS Standalone Mode Web Apps From Opening Links in Safari And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

https://www.pakainfo.com – pakainfo is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development. We deliver the useful and best tutorials for web professionals — developers, programmers, freelancers and site owners. Any visitors of this site are free to browse our tutorials, live demos and download scripts.