The method for setting as homepage is:
<A href = #
OnClick = "this. style. behavior = 'url (# default # homepage) '; this. setHomePage ('url'); event. returnValue = false; "> set as homepage </a>
URL: the specified URL.
In IE, the test is normal, but in firefox, You need to configure it. That is:
Js Code
1 // url: the link to be set as the homepage
2 function SetHomepage (url)
3 {
4 // If the url is blank, the current page url is used by default.
5 if (! Url)
6 {
7 url = document. URL;
8}
9
10 if (document. all) // IE
11 {
12 document. body. style. behavior = 'url (# default # homepage )';
13 document. body. setHomePage (url );
14}
15 else if (window. sidebar) // Firefox
16 {
17 if (window. netscape)
18 {
19 try
20 {
21 window. netscape. security. PrivilegeManager. enablePrivilege ("UniversalXPConnect ");
22}
23 catch (e)
24 {
25 alert ("this operation was rejected by the browser! Enter "about: config" in the address bar of your browser, press enter, set the value of [signed. applets. codebase_principal_support] To 'true', and double-click it. ");
26}
27}
28 var prefs = Components. classes ['@ mozilla.org/preferences-service%1'}.getservice (Components. interfaces. nsIPrefBranch );
29 prefs. setCharPref ('browser. startup. homepage', url );
30}
31}
Add as favorites
Add js Code to favorites
1 // url: the link to be added to favorites; title: The name of the added item
2 function AddFavorite (url, title)
3 {
4 // If the url or title is empty, the current page url and title are used by default.
5 if (! (Url & title ))
6 {
7 url = document. URL;
8 title = document. title;
9}
10
11 if (document. all) // IE
12 {
13 window. external. addFavorite (url, title );
14}
15 else if (window. sidebar) // Firefox
16 {
17 window. sidebar. addPanel (title, url ,"");
18}
19}
Summary: The function is implemented using Get URL and JS.