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. |
|||
|
|||
7 comments :
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.
Thanks.......Suresh
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.
Note: Only a member of this blog may post a comment.