Quantcast
Channel: Add to browser favorites/bookmarks from JavaScript but for all browsers (mine doesn't work in Chrome)? - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by Tony K for Add to browser favorites/bookmarks from JavaScript but for all browsers (mine doesn't work in Chrome)?

$
0
0

I couldnt get the above example to work. Anyway the answer to the original question 'its not working in CHROME and i don't get my error msg saying "not supported" either..' is due to the line

else if (window.external) { // IE 

chrome actually passes this test and then obiously fails to add a bookmark. I changed this line to

else if(window.external && !window.chrome)  // IE

and now you get the 'not supported' message. I actually removed this message and called the function hotKeys() to get a more meaningful alert. I had to make a few changes to get that to work

function showHotKeys() { var ua = navigator.userAgent.toLowerCase(); var str = ''; var isWebkit = (ua.indexOf('webkit') != - 1); var isMac = (ua.indexOf('mac') != - 1); if (ua.indexOf('konqueror') != - 1) {     str = 'CTRL + B'; // Konqueror } else if (window.home || isWebkit || isMac) {     str = (isMac ? 'Command/Cmd' : 'CTRL') +'+ D'; // Netscape, Safari, iCab} return ((str) ? 'Press '+ str +' to bookmark this page.' : str); } 

Viewing all articles
Browse latest Browse all 7

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>