The AddFavorite() JavaScript function can be used in Internet Explorer (version 4 or higher) to add a web address (with a title) to the Internet Explorer favorites. AddFavorite() activates the
function from the
Internet Explorer menu with the given parameters.
The following AddFavorite() call can be used to add the BME website address with its title to the Internet Explorer favorites:
window.external.AddFavorite( 'http://www.bme.ie', 'BME - Baumeister Mediasoft Engineering' );
The following AddFavorite() call can be used to add the currently loaded page to the Internet Explorer favorites:
window.external.AddFavorite(location.href, document.title);
A web browser compatibility check such as
if (window.external) { window.external.AddFavorite(location.href, document.title); }
is recommended since AddFavorite() is only available in Internet Explorer (version 4 or higher).
onclick() can be used to provide a clickable link to the AddFavorite() function call. The following JavaScript code displays a link for adding the currently loaded page to the Internet Explorer favorites:
<script type="text/javascript"> <!--//--><![CDATA[//><!-- if (window.external)
{
document.write(
'<a href="#"'
+ ' onclick="window.external.AddFavorite(location.href,document.title);">'
+ 'Add this Page to your Favorites...</a>'
);
}
//--><!]]> </script>
JavaScript Method AddFavorite (IE4) • © 2025 Manfred Baumeister • Updated: 29 October 2008, 14:15:03 GMT
|