Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a new window on iphone's standalone (fullscreen) mode

<!doctype html>
<html>
<head>
<title>page</title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />

<meta name="apple-mobile-web-app-status-bar-style" content="black" />
</head>
<body>
<script>
function goToPage() {
    var pageUrl = 'http://www.google.com/';
    window.open(pageUrl);
}
</script>
<div id="installBtn" onclick="goToPage()">go to page</div>
</body>
</html>

The expected action is: when touch the div, a new window opens. This code works great in the iPhone's safari.

But when I tap "+" -> "Add to Home Screen", and press "go to page", no window is opened, and the page loads in the same screen.

How to force, by javascript, a new window to open in the standalone mode?

like image 722
Eduardo Abreu Avatar asked Nov 18 '10 12:11

Eduardo Abreu


People also ask

How do I expand a window on my IPAD?

Types of multitasking You can resize the apps by dragging the slider that appears between them. Slide Over: With Slide Over, one app appears in a smaller floating window that you can drag to the left or right side of your screen.


1 Answers

The below question does mention a possible JavaScript solution out of the top voted answers, which constructs the anchor element and dispatches the 'click' event on it.

Question: Force link to open in mobile safari from a web app with javascript
Answer: https://stackoverflow.com/a/8833025/1441046

Alternatively if you can use an anchor element (I know you asked how to do it in JavaScript) you can do the following:

<a id="installBtn" href="http://www.google.com/" target="_blank">go to page</a>

Other related questions:

iPhone window.open(url, '_blank') does not open links in mobile Safari

like image 152
JonWarnerNet Avatar answered Oct 07 '22 08:10

JonWarnerNet