Hasini Posted August 24, 2012 Share Posted August 24, 2012 OK so i've been trying to click the "add to favorites" button on the main page of my Presta, and it isn't working. I am using Chrome browser. I tried with IE and it works. I check the "Elements" in Chrome, and in the Js/tools.js, there is a "mistake": Uncaught TypeError: Object #<Object> has no method 'AddFavorite' return window.external.AddFavorite( url, title); Uncaught TypeError: Object #<Object> has no method 'AddFavorite' (repeated 5 times) else if (window.opera && window.print) (repeated 5 times, because i tried to click it 5 times.) How do i fix it please? Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 27, 2012 Share Posted August 27, 2012 Hi. Google Chrome does not allow adding bookmarks from Javascript, for security reasons. Here's a function that could help you: function add_bookmark(url,page_title) { if(window.sidebar) // Firefox / Mozilla { window.sidebar.addPanel(page_title, url,''); } else if(window.opera) // Opera { var a = document.createElement('A'); a.rel = 'sidebar'; a.target = '_search'; a.title = page_title; a.href = url; a.click(); } else if(window.external) // Inept Exploiter { window.external.AddFavorite(url, page_title); } else { alert(' Your web browser appears to not support adding a bookmark via Javascript. Please manually add one via your browser's bookmark menu. '); } } If the browser does not support adding bookmark by Javascript, the user will be notified to add it manually. Regards. Robin. The CartExpert Team 1 Link to comment Share on other sites More sharing options...
tdr170 Posted August 27, 2012 Share Posted August 27, 2012 Hi. Google Chrome does not allow adding bookmarks from Javascript, for security reasons. Here's a function that could help you: function add_bookmark(url,page_title) { if(window.sidebar) // Firefox / Mozilla { window.sidebar.addPanel(page_title, url,''); } else if(window.opera) // Opera { var a = document.createElement('A'); a.rel = 'sidebar'; a.target = '_search'; a.title = page_title; a.href = url; a.click(); } else if(window.external) // Inept Exploiter { window.external.AddFavorite(url, page_title); } else { alert(' Your web browser appears to not support adding a bookmark via Javascript. Please manually add one via your browser's bookmark menu. '); } } If the browser does not support adding bookmark by Javascript, the user will be notified to add it manually. Regards. Robin. The CartExpert Team That's a good tip but don't you think you should say where to place the line so those with a little less experience can figure it out. Link to comment Share on other sites More sharing options...
fernandokerber Posted August 27, 2012 Share Posted August 27, 2012 Nice. I personally think this bookmark function is obsolete. I do always remove this from my sites. It's much more important having good SEO techniques so that the customers can find your shop on google than having bookmark button. 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 27, 2012 Share Posted August 27, 2012 Nice. I personally think this bookmark function is obsolete. I do always remove this from my sites. It's much more important having good SEO techniques so that the customers can find your shop on google than having bookmark button. Bookmarking and SEO is not the same. It is more comfortable to bookmark a site/page, than to search for it all over again. 1 Link to comment Share on other sites More sharing options...
tdr170 Posted August 27, 2012 Share Posted August 27, 2012 Hi. Google Chrome does not allow adding bookmarks from Javascript, for security reasons. Here's a function that could help you: function add_bookmark(url,page_title) { if(window.sidebar) // Firefox / Mozilla { window.sidebar.addPanel(page_title, url,''); } else if(window.opera) // Opera { var a = document.createElement('A'); a.rel = 'sidebar'; a.target = '_search'; a.title = page_title; a.href = url; a.click(); } else if(window.external) // Inept Exploiter { window.external.AddFavorite(url, page_title); } else { alert(' Your web browser appears to not support adding a bookmark via Javascript. Please manually add one via your browser's bookmark menu. '); } } If the browser does not support adding bookmark by Javascript, the user will be notified to add it manually. Regards. Robin. The CartExpert Team I tried this today, I tried to add to tools.js did not work, I tried to replace the similar code in tools.js did not work, no matter what way I inserted it did not work, it would actually make the bookmark disappear. Prestashop 1.4.7 Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 27, 2012 Share Posted August 27, 2012 That's a good tip but don't you think you should say where to place the line so those with a little less experience can figure it out. As you obviously can not say where this should be done and for the benefit of everyone this is an example. Link to comment Share on other sites More sharing options...
Hasini Posted August 27, 2012 Author Share Posted August 27, 2012 Bookmarking and SEO is not the same. It is more comfortable to bookmark a site/page, than to search for it all over again. I have to agree, a bookmark button is easy to use, and it gives people a push to make themselves your returning customers ($$$). Good SEO is very important but they don't really contradict each other. Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 27, 2012 Share Posted August 27, 2012 That's a good tip but don't you think you should say where to place the line so those with a little less experience can figure it out. If you do not have the coding skills to do this; you are welcome to buy our coding time Link to comment Share on other sites More sharing options...
tdr170 Posted August 27, 2012 Share Posted August 27, 2012 If you do not have the coding skills to do this; you are welcome to buy our coding time I know exactly where to put the code but I thought you might like to reply, anyway it does not work, as you can see from my post above I tried several methods and could not get your code to work. For those of you interested here is something that does work with both 1.4 and 1.5. Change the following code in tools.js located in the js folder: Change this at line 141: function writeBookmarkLinkObject(url, title, insert) { if (window.sidebar || window.external) return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>'); else if (window.opera && window.print) return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>'); return (''); } To this: function writeBookmarkLinkObject(url, title, insert) { if (window.navigator.userAgent.indexOf('Chrome') != -1) return ('<a href="#" class="bookmark_chrome">'+ insert +'<span>Google Chrome Users </br>Press "Ctrl + D" to add to favorites</span></a>'); if (window.sidebar || window.external) return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>'); else if (window.opera && window.print) return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>'); return (''); } Now add the following to Blockpermanentlinks.css in 1.4 add this to blockpermanentlinks.css located in ..themes/yourtheme/css/modules/blockpermanentlinks/ In 1.5 add to blockpermanentlinks.css located in ..modules/blockpermanentlinks .bookmark_chrome span { width:130px; padding:5px; background:#C0C0C0; color:#000; box-shadow:1px 1px 2px #ccc; position:absolute; /* Modify this for your template design*/ top:15px; z-index:999; display:none } .bookmark_chrome:hover span { display:block} Here is a pic of what you will get when you mouse over the bookmark icon: 1 Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 27, 2012 Share Posted August 27, 2012 I know exactly where to put the code but I thought you might like to reply, anyway it does not work, as you can see from my post above I tried several methods and could not get your code to work. For those of you interested here is something that does work with both 1.4 and 1.5. Change the following code in tools.js located in the js folder: Change this at line 141: function writeBookmarkLinkObject(url, title, insert) { if (window.sidebar || window.external) return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>'); else if (window.opera && window.print) return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>'); return (''); } To this: function writeBookmarkLinkObject(url, title, insert) { if (window.navigator.userAgent.indexOf('Chrome') != -1) return ('<a href="#" class="bookmark_chrome">'+ insert +'<span>Google Chrome Users </br>Press "Ctrl + D" to add to favorites</span></a>'); if (window.sidebar || window.external) return ('<a href="javascript:addBookmark(\'' + escape(url) + '\', \'' + escape(title) + '\')">' + insert + '</a>'); else if (window.opera && window.print) return ('<a rel="sidebar" href="' + escape(url) + '" title="' + escape(title) + '">' + insert + '</a>'); return (''); } Now add the following to Blockpermanentlinks.css in 1.4 add this to blockpermanentlinks.css located in ..themes/yourtheme/css/modules/blockpermanentlinks/ In 1.5 add to blockpermanentlinks.css located in ..modules/blockpermanentlinks .bookmark_chrome span { width:130px; padding:5px; background:#C0C0C0; color:#000; box-shadow:1px 1px 2px #ccc; position:absolute; /* Modify this for your template design*/ top:15px; z-index:999; display:none } .bookmark_chrome:hover span { display:block} Here is a pic of what you will get when you mouse over the bookmark icon: That was a snippet for inspirational purposes. Next time try to reply to the question and not criticize. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
Hasini Posted August 28, 2012 Author Share Posted August 28, 2012 (edited) Hey people, i appreciate all the help given, but nothing works. Tried tdr170's method, but still didn't work. ---------------- I am getting a red highlight error on the line "return false;", in js/tools.js if (typeof customizationFields != 'undefined') for (var i = 0; i < customizationFields.length; i++) /* If the field is required and empty then we abort */ if (parseInt(customizationFields[1]) == 1 && ($('#' + customizationFields[0]).html() == '' || $('#' + customizationFields[0]).html() != $('#' + customizationFields[0]).val()) && !pattern.test($('#' + customizationFields[0]).attr('class'))) return false; return true; } Edited August 28, 2012 by Hasini (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 28, 2012 Share Posted August 28, 2012 Hi Hasini. Use this function, this will work with all browsers. You can just overwrite the function addBookmark in tools.js function addBookmark(url, title) { if($.browser.mozilla) { window.sidebar.addPanel(title, url,''); } else if($.browser.opera) { var a = document.createElement('A'); a.rel = 'sidebar'; a.target = '_search'; a.title = title; a.href = url; a.click(); } else if($.browser.msie) { window.external.AddFavorite(url, title); } else { alert(' Your web browser appears to not support adding a bookmark via Javascript. Please manually add one via your browsers bookmark menu. '); } } Regards. Robin. The CartExpert Team 1 Link to comment Share on other sites More sharing options...
Hasini Posted August 28, 2012 Author Share Posted August 28, 2012 Hi Hasini. Use this function, this will work with all browsers. You can just overwrite the function addBookmark in tools.js function addBookmark(url, title) { if($.browser.mozilla) { window.sidebar.addPanel(title, url,''); } else if($.browser.opera) { var a = document.createElement('A'); a.rel = 'sidebar'; a.target = '_search'; a.title = title; a.href = url; a.click(); } else if($.browser.msie) { window.external.AddFavorite(url, title); } else { alert(' Your web browser appears to not support adding a bookmark via Javascript. Please manually add one via your browsers bookmark menu. '); } } Regards. Robin. The CartExpert Team Thank you man, seriously, now it worked, after i found out I was supposed to change the MAIN tools.jr and not the one in my theme. But this is very weird\annoying. It appears that there is an identical script in both about this bookmark! what is that all about??? Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 28, 2012 Share Posted August 28, 2012 Happy to have helped you. The tools.js in the themes folder should not have the bookmark function. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
Hasini Posted August 28, 2012 Author Share Posted August 28, 2012 it does. Link to comment Share on other sites More sharing options...
CartExpert.net Posted August 29, 2012 Share Posted August 29, 2012 Then remove it. Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
v2gaul Posted January 22, 2013 Share Posted January 22, 2013 OK so i've been trying to click the "add to favorites" button on the main page of my Presta, and it isn't working. I am using Chrome browser. I tried with IE and it works. I check the "Elements" in Chrome, and in the Js/tools.js, there is a "mistake": Uncaught TypeError: Object #<Object> has no method 'AddFavorite' return window.external.AddFavorite( url, title); chrome-devtools://devtools/Images/errorIcon.pngUncaught TypeError: Object #<Object> has no method 'AddFavorite' (repeated 5 times) else if (window.opera && window.print) (repeated 5 times, because i tried to click it 5 times.) How do i fix it please? alternative ways without changing the function : Press "Ctrl-D". In order for all visitors to see, change the title "bookmark" to "bookmark (Ctrl-D)". How to edit the file "/ modules / blockpermanentlinks / blockpermanentlinks-header.tpl": (in line 31) <li id="header_link_bookmark"> <script type="text/javascript">writeBookmarkLink('{$come_from}', '{$meta_title|addslashes|addslashes}', '{l s='bookmark' mod='blockpermanentlinks' js=1}');</script> </li> change this : <li id="header_link_bookmark"> <script type="text/javascript">writeBookmarkLink('{$come_from}', '{$meta_title|addslashes|addslashes}', '{l s='bookmark(Ctrl-D)' mod='blockpermanentlinks' js=1}');</script> </li> Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now