Adding your website to favorites and setting as home page

Adding your website to favorites and setting as home page

In this article, we will look at a useful example of adding a site to Favorites and setting it as a home page.

In this article, we will look at a useful example of adding a site to Favorites and setting it as a home page.

You've probably seen links on many sites that allow you to add a site to your favorites or set it as your home page. As a rule, these actions can also be performed using the tools of the browser itself, but the visitor can forget to do this, and if you add the necessary buttons (links) on the site itself, you quietly remind him of this.

Remember, adding a site to your favorites or trying to set it as your homepage without the knowledge of the user is an extremely bad taste, so in no case try to call the example below from the onload event handler of your page.

To add a site to your favorites, use the addFavorite method of the external object. As parameters to this method, you need to pass the page address and its description. Below is a function that implements adding a site to your favorites. It can be used as a link click handler.

function addToFaavorite() {

external.addFavorite("https://sergeyem.ru", 'sergeyem.ru');

widow.alert('Спасибо, что добавили меня в избранное!');

return false;

}

 

--

 

<p><a href="http://sergeyem.ru" onclick="return addToFavorite();">Добавить в избранное</a></p>

 

To set your website as home page you can use following function:

 

function setAsHomePage(obj) {

obj.style.behavior="url(#default#homepage)";

obj.setHomePage('https://sergeyem.ru');

window.alert('Спасибо, что установили мой сайт в качестве домашней страницы!');

return false;

}

 

--

 

<p><a href="https://sergeyem.ru" onclick="return setAsHomePage(this);">Установить в качестве домашней страницы</a></p>