javascript(关闭网页时弹出设为首页这个效果),怎么写?要求能正常运行的,谢谢!

解决方案 »

  1.   

    Javascript设为首页代码可以将网站设置为首页,此代码兼容IE及Firefox 
    come from http://www.5djava.com/ 
    function addHome() 

        if (window.sidebar) 
        { 
            try { 
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
            } 
            catch (e) 
            { 
                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",'http://www.phpuu.com/'); 
        } 
        else if(document.all) 
        { 
            document.body.style.behavior="url(#default#homepage)"; 
            document.body.setHomePage('http://www.phpuu.com/'); 
        } 
        else 
        { 
            ; 
        } 

    调用方式: <a href="javascript:addHome();">设为首页</a> 
      

  2.   

    参考这个http://www.tinybbs.cn/js/post/id~15228
    我也没试过