Javascript bookmark this page in Chrome

I have a stupid client asked me to add “Bookmark this page” to his web pages. I explained to him how bad usability it is but he did not listen to me. He insisted the majority of web users were as stupid as him, so him wanted to help them bookmark the page.

Nevertheless, it is not my site and he is my customer. Customer is the God. So I spent some time digging around and found this script.

<script type="text/javascript">
//<![CDATA[
function bookmark_us(){
var url = window.location;
var title = document.title;

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>

However, Chrome browser does not allow us to bookmark any page using javascript. There is no workaround, and I think Google is absolutely right on this.

My concern is: the above script does not do anything in Chrome. Sooner or later my client will come back to me asking why my script does not work in Chrome. To avoid being questioned, I finally use another solution. It is a jQuery plugin called jBrowserBookmark. It will prompt the correct way to bookmark in unsupported browsers.

Leave a comment

Your email address will not be published. Required fields are marked *