Last updated on March 2nd, 2022 at 07:42 am

Here is a simple script in javascript which shows how you can add a link in your website to make your visitors add the webpage to their Browsers Favorites.

We are using window.external.AddFavorite. 12 years ago when this tutorial was published all browsers supported this property but not anymore. Keeping this for just future reference.

Deprecated: As per Mozilla, this property is no longer recommended. Avoid using it, and update existing code if possible. More details https://developer.mozilla.org/en-US/docs/Web/API/Window/external

<html>
<head>
<script language="JavaScript">

function AddtoFav() {

window.external.AddFavorite('https://www.mistonline.in/wp');

}
</script></head>
<body>
<button onclick="AddtoFav();">
Click here to add www.mistonline.in/wp main page to your favorites
</button>
</body>
</html>

If you run the above code you might most probably hit this error

Uncaught TypeError: window.external.AddFavorite is not a function

Leave a Reply

Your email address will not be published. Required fields are marked *