Create Add to Favorites JS function
<script type= "Text/javascript" >
Define Add to Favorites function
function Join_favorite (SiteURL, SiteName) {
Capturing exceptions in the favorites process
try {
Determine if the browser supports document.all
if (document.all) {
Add external to Favorites if supported
Window.external.addFavorite (Siteurl,sitename);
}else if (Window.sidebar) {
If Window.sidebar is supported, add to favorites in the following ways
Window.sidebar.addPanel (SiteName, SiteURL, ");
}
}
Handling Exceptions
catch (e) {
Alert ("Add to Favorites failed, please use ctrl+d shortcut keys for adding action!");
}
}
</script>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Add to Favorites </title>
<script type= "Text/javascript" >
Define Add to Favorites function
function Join_favorite (SiteURL, SiteName) {
Capturing exceptions in the favorites process
try {
Determine if the browser supports document.all
if (document.all) {
Add external to Favorites if supported
Window.external.addFavorite (Siteurl,sitename);
}else if (Window.sidebar) {
If Window.sidebar is supported, add to favorites in the following ways
Window.sidebar.addPanel (SiteName, SiteURL, ");
}
}
Handling Exceptions
catch (e) {
Alert ("Add to Favorites failed, please use ctrl+d shortcut keys for adding action!");
}
}
</script>
<body>
<a href= "javascript:void (0);" title= "Wecandoitforev-baidujingyan" onclick= "Join_favorite (window.location, Document.title); " > Add to Favorites </a></body>