Question: How do I invoke the browser's Add Favorite dialog?
Answer:
In Internet Explorer 4.0 and newer versions, you can invoke the browser's Add Favorite dialog
by calling the method
window.external.AddFavorite:
window.external.AddFavorite('URL','bookmark text').
Netscape Navigator has no similar method (and no Add Favorite dialog at all).
But your script can just remind Netscape users to create a bookmark
by clicking using the Navigator menu or keyboard shortcut (see the example below).
Example: In Internet Explorer, this script creates a hyperlink that displays the Add Favorite dialog. In Netscape, the script reminds the user to create a bookmark by clicking Bookmarks | Add bookmark or press Ctrl+D.
if (navigator.appName=="Netscape") {
document.write (
'To bookmark this site, click '
+'<b>Bookmarks | Add bookmark</b> '
+'or press <b>Ctrl+D</b>.'
)
}
else if (parseInt(navigator.appVersion)>3) {
document.write (''
+'<a onMouseOver="self.status=\'Bookmark this site\'" '
+' onMouseOut="self.status=\'\'" '
+' href="javascript:window.external.AddFavorite'
+'(\'http://www.JavaScripter.net/faq/\','
+'\'JavaScripter.net FAQ\')">'
+'Click here to bookmark this site</a>.'
)
}
See also other JavaScript dialogs:
Copyright © 1999-2008, JavaScripter.net.