设为首页/加入收藏代码_兼容各浏览器ie系列 Firefox/360 部分不兼容 请自己尝试

来源:互联网 发布:java常用类和方法 编辑:程序博客网 时间:2024/05/21 06:54

<body>  
<script type="text/javascript">  
function  addFav() {   //加入收藏夹   
             if  (document.all) {   
                window.external.addFavorite('http://www.baidu.com', 'baidu');   
            }   
             else   if  (window.sidebar) {   
            window.sidebar.addPanel('baidu', 'http://www.baidu.com',  "" );   
            }   
        }   
function SetHome(obj){   
    try{   
        obj.style.behavior='url(#default#homepage)';   
        obj.setHomePage('http://www.baidu.com');   
    }catch(e){   
        if(window.netscape){   
            try{   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
            }catch(e){   
                alert("抱歉,此操作被浏览器拒绝!/n/n请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为'true'");   
            };   
        }else{   
            alert("抱歉,您所使用的浏览器无法完成此操作。/n/n您需要手动将'http://www.baidu.com/'设置为首页。");   
        };   
    };   
};   
        </script>  
<
a href="javascript:void(0);" onclick="SetHome(this)">设为首页</a>  
<a href="javascript:;" onclick="addFav()">加入收藏</a>  
</body>  
原创粉丝点击