Home   Assembler  Javascript    

 

Javascript "Add to Favorites" code

 

One way to get repeat traffic to your site is to make it easy to visitors to add your page to their favorites. This is really easy for IE4+. It may also be possible for Netscape but the code below is specific for IE.
 

An example of how it could look on your page is shown in the box below.

 

Add this page to your Browser Favorites.


Description to be stored in Favorites

 

 


 

Put the following in your code where you want the "Add to favorites" to appear.

 

<script language="Javascript">

// User must be IE 4+
var FavoriteTitle = document.title
var FavoriteUrl = window.location.href

if (document.all)
{
document.write('<p>');
document.write('<a href="javascript:AddToFavorites()" Class="highlight">Add this page to your Browser Favorites.</a>');
document.write('<form method="POST" action="" name="Favorite">');
document.write('<input type="text" name="Desc" size="30" value ="' + document.title + '" ><br>Description to be stored in Favorites');
document.write('</form>');
document.write('</p>');
}

function AddToFavorites()
{
if (document.all)
window.external.AddFavorite(FavoriteUrl ,FavoriteTitle )
}

</script>