views:

826

answers:

4

Is there a way of telling whether my Web Application has been launched from a button on the user's iPhone home screen? I want to display a "add this WebApp to your home screen" prompt if the user has accessed the WebApp via safari by typing in a URL.

+1  A: 

In Safari, the scrollY will start at a negative value if inside Safari, and at 0 if running as an application.

Likely the viewport will change as well (if it does, this is a more reliable method)

rpetrich
I think the OP is talking about the user opening Safari from a bookmark saved to the user's home screen, not Webkit instances in non-Safari applications
Gareth
Yes, this is what I'm talking about too.
rpetrich
A: 

If I remember correctly there's a thing in the server log that shows what the user's previous page was. So the only way I can think of is if the user was on a previous page display the "add" thing, and if they didn't don't

Matt S.
A: 

jQTouch detects this (try the demo). It's open source, so you should be able to find out how.

ceejayoz
+7  A: 

window.navigator.standalone

True if you have launched from the Home Screen. False if in the Safari browser.

Documented here:

http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

It works with OS 2.1 and up.

Peter

GeoNomad
Thanks! I has just about given up on this one :-)
James