JS兼容所有浏览器的一段加入收藏代码,设置为首页

<script language="javascript" type="text/javascript">
 function addfavorite(obj,url,title) { 
  !url ? url = location.href : null;
  !title ? title = document.title : null;
  try{   
   window.external.addFavorite(url, title); 
   return false;
  }catch(e){   
   try{   
    window.sidebar.addPanel(title, url, ""); 
    return false;  
   }catch(e){   
    alert("加入收藏失败,请使用Ctrl+D进行添加"); 
    if(location.href.toLowerCase().indexOf(obj.href.toLowerCase(),0)>=0){return false;} 
   }   
  }   
 }
</script>
<a href="http://dreamdesign.csrjgzs.com/" onclick="return addfavorite(this,'http://dreamdesign.csrjgzs.com/','阿里西西,最多最全的网页特效集锦!');">收藏阿里西西!</a>

 

设置为首页 

var
strHref=window.location.href;this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.dotneteye.com.cn');

 

posted @ 2014-04-03 11:39  欢醉  阅读(401)  评论(0编辑  收藏  举报