Add to Favorites/Bookmark in javascript

In this tutorial we will learn how to add webpage to the Favorites or how to bookmark a webpage. Let's have a look over the code listed below

<script language="javascript">
function addfav()
{
if (document.all)
{
window.external.AddFavorite
("http://www.nice-tutorials.blogspot.com","Nice Programming Tutorials")
}
}
</script>

I make a custom function and give it a name addfav() whcih will be responsible to bookmark a webpage or add to favorites. Now i am going to call this function by clicking the hyperlink. Let's have a look over the code mentioned below

<a href="javascript:addfav();">Bookmark Us</a>

So this is the way we can add webpage to the Favorites or we can bookmark a webpage in javascript.

Happy Coding

0 comments: