1

Have been searching for an "Add to favorites" piece of code for good 'ol html/js.

Now I am aware of the How do I add an "Add to Favorites" button or link on my website? article. But that is heavily outdated seeing it just doesn't work anymore for most browsers.

So I started this one to see if anyone has an updated piece of coding that works for 2014 at least seeing it would be nice to give my customers a chance to bookmark the pages most important to them. With this in mind it would preferably that it accepts other pages than the current page people are on. If not, than original will more than do.

This one is the original that is outdated:

<script type="text/javascript">
    $(function() {
        $('#bookmarkme').click(function() {
            if (window.sidebar && window.sidebar.addPanel) { // Mozilla Firefox Bookmark
                window.sidebar.addPanel(document.title,window.location.href,'');
            } else if(window.external && ('AddFavorite' in window.external)) { // IE Favorite
                window.external.AddFavorite(location.href,document.title); 
            } else if(window.opera && window.print) { // Opera Hotlist
                this.title=document.title;
                return true;
            } else { // webkit - safari/chrome
                alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'CTRL') + ' + D to bookmark this page.');
            }
        });
    });
</script>
Community
  • 1
  • 1
Matt
  • 1,081
  • 15
  • 27
  • Not a duplicate. Update, seeing the code I posted is exactly that code. – Matt Feb 28 '14 at 18:54
  • No need to update something that still works (and the other post were updated Aug 2013) ... I've tested this code (http://jsfiddle.net/2JXuv/) on all browser but safari and it works perfectly ... which means it becomes a duplicate – Asons Feb 28 '14 at 19:08
  • That code does not work. Well, it does, but not correct. Running FF and getting an alert. So it's basically useless code seeing it would than only work in IE and Opera, the two least used browsers... – Matt Mar 01 '14 at 09:11
  • Useless?, nope, quite the opposite if you ask me. – Asons Mar 01 '14 at 09:30

0 Answers0