Wednesday, March 9, 2011

Add to favorites/Bookmark JavaScript Code

Add to favorites/Bookmark JavaScript Code.


Adding a bookmark to your Web site helps assure that visitors who like your web site and wish to return can easily find it once again.
                        Adding a bookmark is easy to do and does not require any in-depth programming knowledge. It’s a simple matter of cutting and pasting a few snippets of HTML and JavaScript code into a web page script and making a few simple changes to customize it for your site.

Place the following in the head section of the Web page.

<head>
<script type="text/javascript">

function bookmark(url, sitename)
{
       if ((navigator.appName=='Microsoft Internet Explorer') && (parseInt(navigator.appVersion)>=4))
       {
               window.external.AddFavorite(url, sitename);
       }
               else if (navigator.appName=='Netscape')
       {
               window.sidebar.addPanel(sitename, url,"");
       }
}


</script>
</head>



Place the following in your HTML code where you want the bookmark link to appear. 


<a href="javascript:bookmark('http://www.mydomainname.com/', 'My Site Name');">Bookmark This Site</a> 



No comments:

Post a Comment