26 September, 2005
Bookmarking Pages with JavaScript
Internet Explorer Only
Sorry folks, that's life! This can only be done in Microsoft Internet Explorer. In this example we only show the bookmark link if the browser is Internet Explorer.
The Example
<script type="text/javascript">
<!--
if (document.all) {
document.write("<a href="javascript:window.external.AddFavorite(location.href, 'Bookmarking with JavaScript')">Bookmark this page</a>");
} else {
document.write("Sorry, Microsoft Internet Explorer is needed for this example");
}
//-->
</script>
The JavaScript Code
<script type="text/javascript">
<!--
if (document.all) {
document.write("<a href="javascript:window.external.AddFavorite(location.href, 'Bookmarking with JavaScript')">Bookmark this page</a>");
} else {
document.write("Sorry, Microsoft Internet Explorer is needed for this example");
}
//-->
</script>