About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Tutorial archive
General Questions
Javascript 1.2
Navigation
Numbers
Strings
Object Model
Reference Manual
Dialog
Windows
Frames
Forms
Images
Mouse Events
Colors
File Access
Control Status Bar
Dates and Time
Cookies
Client Information
Bookmarklets


Bookmarks: Add Favorite

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.

Here's the source code of this example:
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>.'
 )
}

BackBack