<a href="javascript:void(0);" onClick="SetHome(this,window.location)" style="behavior: url(#default#homepage)">设为首页</a>
<a href="javascript:;" οnclick="addfavor(window.location,document.title)">加入收藏</a>
<script> //设置首页
function SetHome(obj,url){
try{
obj.style.behavior='url(#default#homepage)';
obj.setHomePage(url);
}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您需要手动将【"+url+"】设置为首页。");
}
}
}
//加入收藏
function addfavor(url,title) {
if(confirm("网站名称:"+title+"\n网址:"+url+"\n确定添加收藏?")){
var ua = navigator.userAgent.toLowerCase();
if(ua.indexOf("msie 8")>-1){
external.AddToFavoritesBar(url,title,'');//IE8
}else{
try {
window.external.addFavorite(url, title);
} catch(e) {
try {
window.sidebar.addPanel(title, url, "");//firefox
} catch(e) {
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
}
return false;
}
</script>