You are here: Reference > JavaScript > client-side > browser > methods > AddFavorite (external)

AddFavorite method (external)

Browser support:
Displays the 'Add a Favorite' dialog box for the specified URL and title in Internet Explorer.
Use the addPanel method for similar functionality in Firefox. Opera, Google Chrome and Safari do not provide a way to add new elements to the Favorites (Bookmarks) from JavaScript.

Syntax:

object.AddFavorite (URL [, title]);
You can find the related objects in the Supported by objects section below.

Parameters:

URL
Required. String that specifies the URL of the page that you want to add to the favorites.
title
Optional. String that specifies the name of the page that you want to add to the favorites.

Return value:

This method has no return value.

Example HTML code 1:

This example shows how to add a page to the Favorites (Bookmarks) in Internet Explorer and Firefox.
<head>
    <script type="text/javascript">
        function AddToFavorites () {
            if (window.sidebar) {        // Firefox
                window.sidebar.addPanel ('Dottoro help page', 'http://help.dottoro.com', '');
            } 
            else {
                if (window.external && ('AddFavorite' in window.external)) {
                        // Internet Explorer
                    window.external.AddFavorite ('http://help.dottoro.com', 'Dottoro help page');
                }
                else {  // Opera, Google Chrome and Safari
                    alert ("Your browser doesn't support this example!");
                } 
            }
        }
   </script>
</head>
<body>
    <button onclick="AddToFavorites ();">Add to favorites</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content