Forum Moderators: open
I want to include a link on many of my pages to bookmark the page. I'm sure everyone is familiar with the concept. IE users are presented with a link to click that pops up their "Add to Favorites" window. Netscape users get a message telling them to use CTRL-D on their keyboard.
I found a script at javascriptsource.com that is almost what I need. The problem is, the script (see below) hard-codes the URL to be bookmarked. This won't work on my site because I'm using mostly dynamically-generated pages. The code for the "Bookmark page" script will be in templates that will be used for many different URL's.
So my main question is, what JavaScript can I use to grab the current URL from the address bar and use it for the IE "Add to Favorites" process? Or, how can I modify the below script to accomplish the same purpose?
Any ideas will be appreciated. I've searched here and w3schools.com with no luck so far. Hope somebody can help!
Thanks,
Matthew
<SCRIPT LANGUAGE="JavaScript"><!-- This script and many more are available free online at -->
<!-- The JavaScript Source! [javascript.internet.com...] --><!-- Begin
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {var url="http://www.javascriptsource.com";
var title="The JavaScript Source";document.write('<A HREF="javascript:window.ext');
document.write('ernal.AddFavorite(url,title);" ');
document.write('onMouseOver=" window.status=');
document.write("'Add our site to your favorites!'; return true ");
document.write('"onMouseOut=" window.status=');
document.write("' '; return true ");
document.write('">Add our site to your favorites!</a>');
}
else {
var msg = "Don't forget to bookmark us!";
if(navigator.appName == "Netscape") msg += " (CTRL-D)";
document.write(msg);
}// End -->
</script>