Javascript to add bookmark option on your website

 Rate It (2)

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,'');

}

Revision number 2, Thursday, March 13, 2008 4:54:22 AM by amrelgarhy

Comments

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. bmains (13)
  2. XIII (13)
  3. vik20000in (8)
  4. mbanavige (7)
  5. anas (5)
  6. tmorton (5)
  7. k_nitin_r (3)
  8. binoj7 (3)
  9. scott@elbandit.co.uk (2)
  10. sciguy65 (1)

Advertise Here