Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Add Bookmark link to website using javascript | Add to Favorites (IE) / Bookmark (Firefox) using Javascript

Dec 1, 2011
Introduction

Here I will explain how to add bookmark link to our website using JavaScript in asp.net.

Description

In many websites we will see link like “Bookmark this Site” if we click on that bookmark link that will prompts the user with dialog box to add that specified link in favorites list. If we want to add that type functionality to our website we can write in different ways. Here I will explain in two different ways to add Bookmark functionality

First Method:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Bookmark this Page</title>
<script language="javascript" type="text/javascript">
function addBookmark() {
bookmarkurl = document.URL;
bookmarktitle = document.title;
if (document.all)  //Check the condition for IE
window.external.AddFavorite(bookmarkurl, bookmarktitle)
else if (window.sidebar) // Check the condition for Mozilla
{
window.sidebar.addPanel(bookmarktitle, bookmarkurl, "");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a href="javascript:addBookmark();">Bookmark this page!</a>
</div>
</form>
</body>
</html>
After add above code run your application and check your output it will work for you

Second Method

Now add following code in your aspx page and check it

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Bookmark this Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
 <a href="javascript:if(document.all)window.external.AddFavorite(location.href,document.title);else%20if(window.sidebar)window.sidebar.addPanel(document.title,location.href,'');">Bookmark this Page!</a>
</div>
</form>
</body>
</html>
Demo




If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

7 comments :

Trace IP address said...

very useful writeup. I had been searching the whole place for this and finally found it out on your site. Really appreciate you for your fully informative article. Thank you once again.

Anonymous said...

Thanks.......Suresh

Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...
This comment has been removed by a blog administrator.
Anonymous said...

as i am usinga redirect app , after this add to favourite book mark i need to redirect to next page how can we do this , any one please suggest.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.