Wednesday, May 18, 2011

How to add website in favorites list using ASP.NET and JavaScript

There are couple of ways to add website URL in browser Favorites list,
Just a have a look at below code snippet,

First method,
 <asp:Button ID="btnAddToFavorites" runat="server" Text="Add Me To Favorites List" OnClientClick="window.external.AddFavorite(location.href, document.title);" />

Second method,


<script language="javascript">

function AddToFav()


bookmarkurl= "";

bookmarktitle="Good .NET Articles"

if (document.all)


else if (window.sidebar) // firefox

window.sidebar.addPanel(bookmarktitle, bookmarkurl, "");





<input TYPE="button" VALUE="Add to Favorites" onClick='javascript:AddToFav()' />



No comments: