Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript for "Add to Home Screen" on iPhone?

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?

like image 572
Kerrick Avatar asked Jul 17 '09 08:07

Kerrick


People also ask

How do I enable add on Home Screen iPhone?

You can add shortcuts to the Home Screen, and optionally group them into folders. In My Shortcuts in the Shortcuts app on your iOS or iPadOS device, tap on a shortcut, then tap to open Details. Tap Add to Home Screen.


2 Answers

Until Safari implements Service Worker and follows the direction set by Chrome and Firefox, there is no way to add your app programatically to the home screen, or to have the browser prompt the user

However, there is a small library that prompts the user to do it and even points to the right spot. Works a treat.

https://github.com/cubiq/add-to-homescreen

like image 163
Craig Avatar answered Sep 20 '22 20:09

Craig


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.

like image 35
Louis Gerbarg Avatar answered Sep 18 '22 20:09

Louis Gerbarg