I have updated the javascript code, below, for my website as I noticed the add to favourites link didn’t bookmark websites in Firefox. I have now updated the code so that this is compatible with both Firefox and IE but I’ve noticed this is opening the url in the sidebar window instead of a full browser page. If anyone knows how to fix this please let me know as so far I’ve only found examples which do the same or only work in IE.
Firefox add to favorites code:
<script type=”text/javascript”>
function bookmarksite(){
if (document.all)
window.external.AddFavorite(location.href, document.title);
else if (window.sidebar)
window.sidebar.addPanel(document.title, location.href, “”)
}
<% /script>
<% a href=”javascript:bookmarksite()”> Add to favorites< /a>














thanks, works well
Do you know the code for Safari and Opera? just curious.
Not tested but I believe the code for safari would be something like:
a href=http://www.google.com” title=”Google web search” rel=”sidebar”
As for Safari I have no idea, I found this page while googling how to do it in Safari.
it dosent work
thanks for code..i will use it.
good script.. I will use it in one of my sites!
Nothing works for me. If someone can send me a code that works, I will pay!
edit quotes after you copy-paste the code and it will work fine..
I tested it and it doesnt wor in mozila firefox 3.05
I found a script that works:
/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
/* 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);
}
Bookmark this site!
@Online
Thanks a lot for the script, i just think that the order of the if statements should be changed to ie, firefox and opera at the end