Set as homepage JS, add to favorites JS, add to favorites Code, set as homepage code, Firefox is compatible with IE
Keywords: set as homepage JS, add to favorites JS, add to favorites Code, set as homepage code, compatible with Firefox, add to favorites, set as homepage, and 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:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> compatible with FF, add to favorites, and set as homepage </title>
<Script 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 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>
</Head>
<Body>
<A onclick = "AddFavorite (window. Location, document. Title)"> Add to favorites </a>
<A onclick = "sethome (this, window. Location)"> set as homepage </a>
</Body>
</Html>