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?
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?
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.
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.
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.
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.
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.
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.