Set as homepage JS, add to favorites js, add to favorites Code, set as homepage code, compatible with Firefox add to favorites and set as homepage, FF set as homepage JS, add to favorites js, add to favorites Code, set as homepage code, compatible with Firefox
Add to favorites and set as homepage, FF as Homepage
In one setting, I found that Firefox (FF) does not support adding favorites and setting them as the homepage like IE, so I found the FF method. Then I tested it and can use it .. The Code is as follows:
Html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN"
"Http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
Xmlns = "http://www.w3.org/5o/xhtml”>
Http-equiv = "Content-Type" content = "text/html; charset = gb2312 ″
/>
Compatible with FF, add to favorites, and set as Homepage
LANGUAGE = "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 was rejected by the browser! \ N enter "about: config" in the address bar of the browser, press enter \ n, and then
Set the value of [signed. applets. codebase_principal_support] To 'true'. Double-click it .");
}
Var prefs =
Components. classes ['@ mozilla.org/preferences-service%1'%.getservice (Components. interfaces. nsIPrefBranch );
Prefs. setCharPref ('browser. startup. homepage', vrl );
}
}
}
//->
SCRIPT
Onclick = "AddFavorite (window. location, document. title)"> Add to favorites
Onclick = "SetHome (this, window. location)"> set as Homepage