<A onclick = "SetHome (this, window. location)"> set as homepage </a>
<A onclick = "AddFavorite (window. location, document. title)"> Add to favorites </a>
<Script type = "text/javascript">
Function AddFavorite (sURL, sTitle ){
Try {
Window. external. addFavorite (sURL, sTitle );
}
Catch (e ){
Try {
Window. sidebar. addPanel (sTitle, sURL ,"");
}
Catch (e ){
Alert ("failed to add to favorites, please add with Ctrl + D ");
}
}
}
Function SetHome (obj, vrl ){
Try {
Obj. style. behavior = 'url (# default # homepage) '; obj. setHomePage (vrl );
}
Catch (e ){
If (window. netscape ){
Try {
Netscape. security. PrivilegeManager. enablePrivilege ("UniversalXPConnect ");
}
Catch (e ){
Alert ("this operation is rejected by the browser! \ N enter "about: config" in the address bar of the browser, press enter \ n, set the value of [signed. applets. codebase_principal_support] To 'true', and double-click it. ");
}
Var prefs = Components. classes ['@ mozilla.org/preferences-service%1'}.getservice (Components. interfaces. nsIPrefBranch );
Prefs. setCharPref ('browser. startup. homepage', vrl );
}
}
}
</Script>