Sunday, February 12, 2012

How to check whether the user has a bookmark (iPhone)


For mobile web development: I am making a website which asks the user (on an iPhone or iPod Touch) to save the page as a bookmark on the homescreen.



I do not want to show this message when the user already has a bookmark, so how can I check that (preferably using JavaScript, I don't know any other way).



Any tips are welcome.

2 comments:

  1. You can check it with JavaScript via window.navigator.standalone. Look here for details.

    if (("standalone" in window.navigator) &&!window.navigator.standalone) {
    // Show the text for adding it as a 'bookmark'/app on home screen.
    }

    ReplyDelete
  2. You can use this meta tag in your index file
    <meta name="apple-mobile-web-app-capable" content="yes" />

    EDIT: To clarify: when the user uses to bookmark to access the page, the message shouldn't be displayed anymore. I have used the JS project Add 2 Home with success

    ReplyDelete