Set as Homepage, Bookmark a page

The following javascript code snippet allows a user to add your page as homepage, and to bookmark (favorite) your page.

The following javascript function code allows you to add the current address location as the Homepage of your browser.
function setHome(){
      document.body.style.behavior='url(#default#homepage)';
      document.body.setHomePage(window.location.href);
}
The following javascript function code adds the current address location to your browser’s Bookmarks list, and the document title is set as the title (name) of the Bookmark.
function setBookmark() {
      var title = document.title;
      var address =  window.location.href;
      if(window.sidebar) {
            window.sidebar.addPanel(title,address);
      } else if(window.external) {
            window.external.AddFavorite(address,title);
      } else if(window.opera && window.print) { 
            var elem = document.createElement('a');
            elem.setAttribute('href',address);
            elem.setAttribute('title',title);
            elem.setAttribute('rel','sidebar');
            elem.click();
      }
}
The problem with the above codes is that the ‘Homepage’ code works only in Internet Explorer, and the ‘Bookmark’ code is somewhat erry in Firefox (bookmarked page opens in sidebar).
But there is another option available though not javascript. The addthis site provides you with a custom button that can be added to your site/blog, that not only allows to bookmark your page but also provides you with data related to how and where the content is being shared.

7 comments:

  1. Is there any update available for Chrome ?

    ReplyDelete
  2. The 'Set HomePage' functionality is not supported in Firefox/Chrome browsers, due to security concerns. Also it has been disabled in IE from IE8 version. The best workaround is to give your users instructions on how to manually set the home page.

    ReplyDelete
  3. Thanks, I been trying to add bookmark for a while

    ReplyDelete
  4. this is not working now on chrome

    ReplyDelete
  5. nice info about bookmarking thank you i will check it for sure..

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...
 

Copyright © 2012 | ScriptSplash | Powered by Blogger Templates