Mad Joe said the following on 5/5/2007 3:36 PM:
// Firefox 1.x+, IE4+ and Opera7+
And broken in many of those and others.
<script type="text/javascript">
<!-- // Begin
Remove the worthless, non-working, useless comments.
function bookmarksite(title,url){
if (window.sidebar) // Firefox
While Firefox may support sidebar, it may not be the only browser that
does. But, at least this branch of the if half tests for what you are using.
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // Opera
Is there a browser (or even a version of Opera) that doesn't support
window.print? And, why aren't you testing for what you really want to use?
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all) // IE
IE is far from the only browser that will enter this branch. AOL, for
one, will pass that test but utterly error out on the call to
window.external, and, there is *no* way to add a favorite in AOL via
scripting.
window.external.AddFavorite(url, title);
}
// End -->
</script>
<a href="javascript:bookmarksite('Page Title',
'http://www.example.com')">Bookmark this site!</a>
What happens if scripting is disabled? And, what happens, in IE, when an
animated gif is on the page? (Test it).
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/