i trying implement cross-browser bookmark functionality , found on so: how add "add favorites" button or link on website?
now, using @phpst's answer..
<script type="text/javascript"> $(function() { $("#bookmarkme").click(function() { if (window.sidebar) { // mozilla firefox bookmark window.sidebar.addpanel(location.href,document.title,""); } else if( /*@cc_on!@*/false) { // 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 bookmark page.'); } }); }); </script> it works on plain webpage.. demonstrated here: http://jsfiddle.net/gxas4/
but when use inside wordpress template, in chrome js error this:
uncaught typeerror: object #<htmldivelement> has no method 'addpanel' it not return error on console of firefox not too.
a lot of posts on have questions starting ('uncaught typeerror: object # has no method') nothing seems point me right direction.
has have idea why happening?
it's possible wordpress theme using has element id=sidebar.
unless global variable same name has been explicitly defined, global variable created each element has id.
so, first test unreliable. example, evaluating window.sidebar on stackoverflow page true in chrome, because website uses element such id.
Comments
Post a Comment