Welcome to W3Courses
 Like Us on Facebook

Create an Add to Favorite link using Javascript

You can create a link named Add to Favorites and when a user clicks on it, the link will prompt the user to add your site to their favorites. Use the following code to implement this solution:

<HTML>
<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!-- //Hide From Old Browsers

/* Do Not Remove the Following Line
   For more scripts visit http://www.w3courses.com
*/

//Change the following link to yours
var link = "http://www.w3courses.com";

//Replace the following link with your title
var title = "W3courses";

//Function
function fav()
{
     if(document.all)
          window.external.AddFavorite(link,title)
}

// End Hide-->
</SCRIPT>

<A HREF="#" onClick="fav();">Add To Favorites</A>

</BODY>
</HTML>
 

Share