views:

4426

answers:

6

Is it possible to use Javascript to emulate the Add to Home Screen option in Mobile Safari's bookmark menu?

Something similar to IE's window.external.AddFavorite(location.href, document.title); possibly?

+7  A: 

The only way to add any book marks in MobileSafari (including ones on the home screen) is with the builtin UI, and that Apples does not provide anyway to do this from scripts within a page. In fact, I am pretty sure there is no mechanism for doing this on the desktop version of Safari either.

Louis Gerbarg
Thanks, I was afraid not. I decided to check `window.navigator.standalone` and urge them to add it if it in running in Mobile Safari.
Kerrick
Eugh. Begging people to bookmark you? How obnoxious.
David Dorward
@David - I disagree, it's not an obvious feature to many.
Matt Huggins
@David Not for web-apps. It's not many users that know they can bookmark to the home screen. IMHO it would be nice with a link/button that fires the dialog with a helpful message.
gregers
+6  A: 

I disagree with David Dorward; many people are unfamiliar with the 'add to home screen' feature on the iPhone, so providing the user a simple link so they can add frequently visited sites to their home screen would be a valuable tool.

Michael McWatters
Agreed. Google does this with some of their iPhone web apps.
tedmiston
A: 

Come on - imagine the pollution of silly "ADD TO HOME SCREEN - TAP HERE" Links on Websites! No way - If you have content worth bookmarking, the users will do - and learn. This feature is obnoxious.

l-i-n-k
I disagree. I feel that as long as you use a cookie and only show it on a user's first visit to a site, it would be rather helpful for new iOS adopters.
Justin
+1  A: 

The goal here, I'm assuming, is to help users to 'install' webapps on their iPhone. If you've built your iPhone app using CSS/HTML/JS, and don't want to deal with the App Store, you can mimic 90% of the behavior and look of a native app if you're able to get the user to start the webapp from a bookmark on their home screen (you can hide the Safari chrome, for instance).

So, if you're able to get the user to create this bookmark on the home screen seamlessly -- a javascript method to jumpstart that process would be a great start -- then the differences between a webapp and native app would mostly fall away for the end user.

Tom Genoni
Agreed. Every javascript game I've installed on my iPhone uses this technique. I feel it's equivalent to the "buy now" button in the app store.
kubi
A: 

I would add that browser-based apps for Mobile Safari are only presented correctly (without the URL bar, etc.) when launched from a bookmark on the home screen. This makes it more than just desirable to streamline bookmarking a link on the home screen -- it is actually desirable to dissuade users from opening the web app through other means which will not result in the desired presentation.

It seems inconsistent that Apple supports installing native apps by clicking in the browser, but doesn't allow installing links to Web pages in a similar way. Even if Apple simply added a "Bookmark" selection to the context menu for links, that would help a lot. In that case, one could disable a link's click event to prevent it from being followed directly, and then display instructions telling the user to install by first touching/holding the link, and then selecting Bookmark -> Add to Home Screen.

Steve Jorgensen
A: 

There is an open source Javascript library that offers something related : mobile-bookmark-bubble

The Mobile Bookmark Bubble is a JavaScript library that adds a promo bubble to the bottom of your mobile web application, inviting users to bookmark the app to their device's home screen. The library uses HTML5 local storage to track whether the promo has been displayed already, to avoid constantly nagging users.

The current implementation of this library specifically targets Mobile Safari, the web browser used on iPhone and iPad devices.

Philippe Laval