Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Javascript to add bookmark option on your website

0.00/5 (No votes)
12 Mar 2008 1  
If it is required to add a facility on the webpage that users can click a button on the website and it will open up bookmark option. Following is

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

If it is required to add a facility on the webpage that users can click a button on the website and it will open up bookmark option. Following is the code that will perform this task.

<html>
<body>
<SCRIPT LANGUAGE="JavaScript">
function bookmark(url, description)
{
if (navigator.appName=='Microsoft Internet Explorer')
{
window.external.AddFavorite(url, description);
}
else
{
alert('This option works with IE only as of now.');
}
}

</SCRIPT>
<input type="Button" ID="btnBookMark" onClick="bookmark('http://mypage.aspx','MyWebsite')" value="Bookmark" />
</body>
</html>

 

-And if you want it work in IE and firefox as well:

function addToBookMarks()

{

if(document.all)

window.external.AddFavorite(location.href,document.title);

else if(window.sidebar)window.sidebar.addPanel (document.title,location.href,'');

}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here