Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function addCookie ()
{
If (document. all)
{
Window. external. addFavorite ('HTTP: // www.jb51.net', 'feet home ');
}
Else if (window. sidebar)
{
Window. sidebar. addPanel ('feet home', 'HTTP: // www.jb51.net ',"");
}
}
Function setHomepage ()
{
If (document. all)
{
Document. body. style. behavior = 'url (# default # homepage )';
Document. body. setHomePage ('HTTP: // www.jb51.net ');
}
Else if (window. sidebar)
{
If (window. netscape)
{
Try
{
Netscape. security. PrivilegeManager. enablePrivilege ("UniversalXPConnect ");
}
Catch (e)
{
}
}
Var prefs = Components. classes ['@ mozilla.org/preferences-service%1'}.getservice (Components. interfaces. nsIPrefBranch );
Prefs. setCharPref ('browser. startup. homepage', 'HTTP: // www.jb51.net ');
}
}
</Script>
<Form>
<A href = "#" onclick = "return setHomepage ();"> set as homepage </a>
<A href = "#" onclick = "return addCookie ();"> Add to favorites </a>
</Form>