代码
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head runat="server">
3 <title>无标题页</title>
4 <script language="javascript" type="text/javascript">
5 function AddFavorite(sURL, sTitle)
6 {
7 try
8 {
9 window.external.addFavorite(sURL, sTitle);
10 }
11 catch (e)
12 {
13 try
14 {
15 window.sidebar.addPanel(sTitle, sURL, "");
16 }
17 catch (e)
18 {
19 alert("加入收藏失败,请使用Ctrl+D进行添加");
20 }
21 }
22 }
23 function SetHome(obj,vrl){
24 try{
25 obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
26 }
27 catch(e){
28 if(window.netscape) {
29 try {
30 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
31 }
32 catch (e) {
33 alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
34 }
35 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
36 prefs.setCharPref('browser.startup.homepage',vrl);
37 }
38 }
39 }
40 </script>
41
42 </head>
43 <body>
44 <form id="form1" runat="server">
45 <a onclick="AddFavorite(window.location,document.title)" style="cursor:pointer">加入收藏</a>
46 <a onclick="SetHome(this,window.location)" style="cursor:pointer">设为首页</a>
47 </form>
48 </body>
49 </html>
2 <head runat="server">
3 <title>无标题页</title>
4 <script language="javascript" type="text/javascript">
5 function AddFavorite(sURL, sTitle)
6 {
7 try
8 {
9 window.external.addFavorite(sURL, sTitle);
10 }
11 catch (e)
12 {
13 try
14 {
15 window.sidebar.addPanel(sTitle, sURL, "");
16 }
17 catch (e)
18 {
19 alert("加入收藏失败,请使用Ctrl+D进行添加");
20 }
21 }
22 }
23 function SetHome(obj,vrl){
24 try{
25 obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
26 }
27 catch(e){
28 if(window.netscape) {
29 try {
30 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
31 }
32 catch (e) {
33 alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
34 }
35 var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
36 prefs.setCharPref('browser.startup.homepage',vrl);
37 }
38 }
39 }
40 </script>
41
42 </head>
43 <body>
44 <form id="form1" runat="server">
45 <a onclick="AddFavorite(window.location,document.title)" style="cursor:pointer">加入收藏</a>
46 <a onclick="SetHome(this,window.location)" style="cursor:pointer">设为首页</a>
47 </form>
48 </body>
49 </html>