2009 - 04 - 11 Compatible with IE and Firefox, It is set as the home page and the favorite Javascript Code Function Addcookie (){ // Add to favorites
If (Document. All ){
Window. External. AddFavorite ( ' Http://taotao.wsyren.com ' , ' Niu Ba ' );
}
Else If (Window. Sidebar ){
Window. Sidebar. addpanel ( ' Niu Ba ' , ' Http://taotao.wsyren.com ' , "" );
}
}
Function SetHomePage (){ // Set Homepage
If (Document. All ){
Document. Body. style. Behavior = ' URL (# default # homepage) ' ;
Document. Body. setHomePage ( ' Http://taotao.wsyren.com ' );
}
Else If (Window. Sidebar ){
If (Window. Netscape ){
Try {
Netscape. Security. privilegemanager. enableprivilege ( " Universalxpconnect " );
}
Catch (E ){
Alert ( " This operation is rejected by the browser. To 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://taotao.wsyren.com ' );
}
}
From: http://csprogrammer.blog.51cto.com/212533/51081
Call method:
< A Href = "Javascript: void (0 )" Onclick = "SetHomePage ()" > Set as Homepage </ A >
< A Href = "Javascript: void (0 )" Onclick = "Addcookie ()" > Add to favorites </ A >