Answer the question
In order to leave comments, you need to log in
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
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), чтобы добавить страницу в Избранное');
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question