Set as homepage and add favoritesCode, Can be seen everywhere, find the website, ViewSource codeThat's all. It's generally implemented in Js ..
Code <! 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 > 9421 Test </ Title >
</ Head >
< Body >
< Script Type = "Text/JavaScript" >
Function SetHomePage (){ // Set Homepage
If (Document. All ){
Document. Body. style. Behavior = ' URL (# default # homepage) ' ;
Document. Body. setHomePage ( ' Http://www.9421.org ' );
}
Else If (Window. Sidebar ){
If (Window. Netscape ){
Try {
Netscape. Security. privilegemanager. enableprivilege ( " Universalxpconnect " );
}
Catch (E ){
Alert ( " The [set as homepage] function is not enabled in your browser. Enable this function: Enter about: config in the address bar, and set the value of signed. Applets. codebase_principal_support to true. " );
}
}
VaR Prefs = Components. classes [ ' @ Mozilla.org/preferences-service=1 ' ]. Getservice (components. Interfaces. nsiprefbranch );
Prefs. setcharpref ( ' Browser. startup. Homepage ' , ' Http://www.9421.org ' );
Alert ( " The settings are complete! " );
}
}
Function Addcookie (){ // Add to favorites
If (Document. All ){
Window. External. AddFavorite ( ' Http://www.56beijing.org ' , ' 9421 Test ' );
}
Else If (Window. Sidebar ){
Window. Sidebar. addpanel ( ' 9421 Test ' , ' Http://www.9421.org ' , "" );
}
}
</ Script >
< A Onclick = "Javascript: setHomePage ();" Href = "#" > Set homepage | </ A >
< A Href = "#" Onclick = "Javascript: addcookie ();" > Add to favorites </ A >
</ Body >
</ Html >
Key code:
Document. Body. setHomePage ('HTTP: // www.9421.org ');
/// Var prefs = components. classes ['@ mozilla.org/preferences-service%1'}.getservice (components. Interfaces. nsiprefbranch );
/// Prefs. setcharpref ('browser. startup. homepage', 'HTTP: // www.9421.org ');
Window. External. AddFavorite ('HTTP: // www.56beijing.org ', '9421test ');
/// Window. Sidebar. addpanel ('9421test', 'HTTP: // www.9421.org ',"");
Browser judgment:
If (document. all) {
window. external. addFavorite ('HTTP: // www.56beijing.org ', '9421test');
}< br> else if (window. sidebar) {
window. sidebar. addpanel ('9421test', 'HTTP: // www.9421.org ', "");
}