Search code examples
javascriptiphonemobile-safaribookmarkshomescreen

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?


Solution

  • TLDR: @Craig has a better answer above.

    Below is my original answer, but I do not believe it answers the question adequately. Today I would say you'd have to try a library to emulate this effect, as A2HS is not supported in WebViews (PWAs).

    @Kerrick I would like to delete my answer, but cannot as it has been accepted.

    Old answer:

    Yes. The majority of modern browsers support the Add to Home screen (or A2HS) feature for Progressive Web Apps. To quote the Mozilla Web Docs article:

    Add to Home screen is a feature available in modern browsers that allows a user to "install" a web app, ie. add a shortcut to their Home screen.

    See also: A2HS browser support at caniuse.com