monsieur_h
monsieur_h

Reputation: 1380

How to close a iPad webapp and open safari?

I'm working on a webapp for iPad. What I want is provide a "save & quit" option. When the user presses the quit button, I safely update my database and show a screen who thanks the user for using the webapp.

What I want to do now is actually close the webapp. As window.close(); doesn't seems to work I have found a workaround with links.

Clicking on a link in a webapp closes the fullscreen app and opens safari. So far I tried to embed an hidden link in my mage and trigger it with link.onclick(); but it doesn't work, and document.location= doesn't open safari.

Here's the HTML example:

<body onload="leave();">
  Modifications saved, goodbye!
  <a id="goodbye" href="www.mahsite.com" style="display:none;">&nbsp;</a>

And the JS:

function leave() {
            window.close();//Doesn't work
            window.setTimeout(function e(){document.getElementById('goodbye').onclick();},1000);
            return true;
        }

Can someone give me an idea? I'm aware that the onclick() won't work unless I have a onclick handler attached to my link, but I don't have any other idea.

Upvotes: 1

Views: 1449

Answers (1)

andreamazz
andreamazz

Reputation: 4286

Try

self.close();

or

self.window.close();

Upvotes: 1

Related Questions