Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JavaScript Bookmark Code
Author Message
Admin Offline
Administrator
*******

Posts: 54
Joined: Nov 2009
Reputation: 0
Post: #1
JavaScript Bookmark Code
Place the following in the head section of the Web page.

Code:
<script type="text/javascript">
function bookmarksite(title,url){
if (window.sidebar) // firefox
    window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
    var elem = document.createElement('a');
    elem.setAttribute('href',url);
    elem.setAttribute('title',title);
    elem.setAttribute('rel','sidebar');
    elem.click();
}
else if(document.all)// ie
    window.external.AddFavorite(url, title);
}
</script>

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

Code:
<a href="javascript:bookmarksite('Website Name', 'http://www.mywebsite.com')">Bookmark this site!</a>

Be sure to substitute your site’s domain name for mydomainname.com in the sample code and the name you want to appear in the user’s bookmark in place of My Site Name.

There is one caveat with bookmark code. Because it uses JavaScript, it will not function if JavaScript is disabled in a user’s browser. JavaScript must be enabled for this code to work. That means that there are a small percentage of users who cannot bookmark a site using this code.
(This post was last modified: 11-28-2009 12:07 PM by Admin.)
11-28-2009 12:02 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump: