兼容ie或火狐的设为首页和加入收藏的javascript代码,分享给大家:
- <script type="text/javascript">
- function addFav()
- {
- if (document.all)
- {
- window.external.addFavorite("http://www.pageadmin.net","pageadmin cms");
- }
- else if(window.sidebar)
- {
- window.sidebar.addPanel("pageadmin cms", "http://www.pageadmin.net", "");
- }
- }
- function SetHome(obj)
- {
- try
- {
- obj.style.behavior="url(#default#homepage)";
- obj.setHomePage("http://www.pageadmin.com");
- }
- catch(e)
- {
- if(window.netscape)
- {
- try{ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}
- catch(e){ alert("抱歉,您所使用的浏览器无法完成此操作。"); }
- }
- else
- {
- alert("抱歉,您所使用的浏览器无法完成此操作。");
- }
- }
- }
- </script>
- <a href="javascript:SetHome(this)">设为首页</a>
- <a href="javascript:addFav()">加入收藏</a>
复制代码