`

主页和收藏网页代码

阅读更多

<!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>支持IE6和火狐最新版的JS添加首页、收藏夹</title> 
    </head> 
     
    <body> 
     
    <script type="text/javascript"> 
     
    function homePage(obj,val){ 
      try{ 
                    obj.style.behavior='url(#default#homepage)'; 
                    obj.setHomePage(val); 
            } 
            catch(e){ 
                    if(window.netscape) { 
                            try { 
                                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
                            }  
                            catch (e)  { 
                                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                                   alert("此操作被浏览器拒绝!\n请在浏览器地址栏输入“about:config”并回车\n然后将

[signed.applets.codebase_principal_support]设置为'true'"); 
                            } 
                            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService

(Components.interfaces.nsIPrefBranch); 
                            prefs.setCharPref('browser.startup.homepage',val); 
                     } 
            } 
     } 
     
     
     
    function addFavorite() { 
        var a = document.URL.split("/"); 
        var c = "http://" + a[2] + "/"; 
        var b = document.title; 
        try { 
            window.external.AddFavorite(c, b) 
        } catch (d) { 
            window.sidebar.addPanel(b, c, "") 
        } 
    }; 
     
     
    </script> 
    <a href="#"onclick="homePage(this,'www.hao123.com')" >设为首页JAVAEYE</a> 
     
    <span title="将多玩游戏网加入收藏夹" onclick="addFavorite();" style="cursor:pointer">加入收藏</span> 
    </body> 
    </html> 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics