Hi, I am encountering some problems with this javascript, can someone please help me take a look at it, and see why won't it function as intended? Did i mess up something? <script language="JavaScript" type="Text/Javascript"> var urlAddress = "http://xxx.xxx.xxx/"; var pageName = "xxx"; function addToFavorites() { if (window.external) { window.external.AddFavorite(urlAddress,pageName) } else { alert("Sorry! Your browser doesn't support this function."); } } </script> ** in body i got this <a href="javascript:addToFavorites()"><font color="#7B1421">Bookmark Us</font></a> ** thanks.
Don't know, but this is what I use: <SCRIPT LANGUAGE="javascript"> //This code is for IE v4 or better if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion >= "4.0") {document.write("<SPAN style='cursor:hand;' onClick='window.external.AddFavorite(location.href, document.title);'>Add to favorites</SPAN></strong>")} //This code posts text if not else {document.write("Hit CTRL-D to bookmark this page")} </SCRIPT> Code (markup): hth, amofw
You didn't specify what your problems are, but here is working code; <script type="text/javascript"> function bookmark(url, label) { if(window.external) { external.AddFavorite(url, label); } else { alert("you have a DOM compliant browser" + "\nthat doesn't run proprietary JScript."); } } </script> =========== <a href="#" onclick="bookmark(this.href, 'title for the page'); return false;"> bookmark</a> Code (markup): cheers, gary
it's good. you can use the CTR+D insted of "Sorry! Your browser doesn't support this function" firefox and mozila use the same
Try this, it should work in IE, FireFox, and Opera: <a href="" rel="sidebar" onclick="if(document.all && !window.opera){ window.external.AddFavorite(location.href, document.title); return false; }else{ this.title = document.title; }">Add to Favorites</a> Code (markup):