S
S
SergeyKisliy2016-05-29 08:36:00
JavaScript
SergeyKisliy, 2016-05-29 08:36:00

How to make a button - add to home screen / bookmarks (mobile / desktop)?

Hello.
What are the current best practices for creating a link/button on a site that, when clicked, adds the site to bookmarks on the desktop? And how to make sure that on a mobile phone, the site is added not to bookmarks, but to the main screen (otherwise, why make a bunch of favicons for all types of devices =))?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2016-05-29
@SergeyKisliy

These are two completely different questions.
1. About the desktop - it's somewhere like this:

function bookmark(a) {
  title=document.title;
  url=document.location;
    try { 
     window.sidebar.addPanel(title, url, "");
    } catch (e) {
      if (window.opera && window.print || typeof(window.sidebar)=="object") {  // Opera || Mozilla
        a.rel="sidebar";
        a.title=title;
        a.url=url;
        a.href=url;
        return true;
      } else if(document.all) {  //  Internet Explorer
          window.external.AddFavorite(url, title);
          return true;
      }  else {
         alert('Нажмите Ctrl+D (Cmd+D на MacOS), чтобы добавить страницу в Избранное');
      }
   }
}

2. About adding to the main screen for Android: here
Sample application: here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question