Please visit my new Web Site https://coderstechzone.com
Developers basically use shortcut command to add a page into favorite list or bookmark list but most of the users does not know how they can add an important page into their favorite list or bookmark list. Thats why if developer add a bookmark link or add to favorite link on important pages so that users can easily bookmark the page. Here in this article i will explain how one can add favorites link or bookmark link in a page using cross browser javascript code. My example will work on Internet explorer, Opera and Mozilla Firefox like below:
To implement my example code first add a aspxa page into your project then under HTML head tag add the below javascript method to bookmark or add to favorites:
<script type="text/javascript"> function Add_Bookmark_Favorite(url,title) { if (window.sidebar) { // Mozilla Firefox Bookmark //Make sure "Load this bookmark in the sidebar is deselected window.sidebar.addPanel(title, url,""); return false; } else if( window.external ) { // IE Favorites window.external.AddFavorite( url, title); return false; } else if(window.opera && window.print) { // Opera Bookmark return !addToFav(url,title) } } </script>
Now add the below link into your asp.net aspx page like below:
<a href="" title="" rel="sidebar" onclick="return Add_Bookmark_Favorite(location.href, document.title);">Bookmark / Add to Favorites</a>
Now run the page and click on the "Bookmark / Add to Favorites" link will popup a window to bookmark this page.
3 comments:
it's all great but doesn't work with IE. it just goes to the home page when clicked. but it's ok with opera and firefox. what can be wrong?
and is there a way to make it work with google chrome too?
this is good it is working
Its a superrr article
I WOULD BE DELIGHTED TO HEAR FROM YOU