This is a cross browser (Firefox 1.x+, IE4+ and Opera7+) script for allowing the user to easily bookmark your site, by clicking on a link on the page.
Demo: (You can use either an image link or a regular text link)
Bookmark Dynamic Drive!
Step 1:
Add the below code to the section of your page:
Step 2:
Create either an image or text link that will be used as the Bookmark Site link. For the href attribute, use the following code:
javascript:bookmarksite('title_of_site', 'url_of_site')
Here's an example:
<a href="javascript:bookmarksite('Transhopers', 'http://www.transhoper.co.cc')">Bookmark this site!</a>
Remember, if your site's title contains apostrophes, they need to be backslashed when entered:
<a href="javascript:bookmarksite('trans\'s hopers', 'http://www.google.com')">Bookmark this site!</a>
Demo: (You can use either an image link or a regular text link)
Bookmark Dynamic Drive!
Step 1:
Add the below code to the section of your page:
<script type="text/javascript">
/* Modified to support Opera */
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>
/* Modified to support Opera */
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>
Step 2:
Create either an image or text link that will be used as the Bookmark Site link. For the href attribute, use the following code:
javascript:bookmarksite('title_of_site', 'url_of_site')
Here's an example:
<a href="javascript:bookmarksite('Transhopers', 'http://www.transhoper.co.cc')">Bookmark this site!</a>
Remember, if your site's title contains apostrophes, they need to be backslashed when entered:
<a href="javascript:bookmarksite('trans\'s hopers', 'http://www.google.com')">Bookmark this site!</a>