<html>  <head>  <script>  function addCookie(){  // 加入收藏夹   if (document.all){   window.external.addFavorite('http://www.caidao8.com', '财刀网');   }else if (window.sidebar){   window.sidebar.addPanel('财刀网', 'http://www.caidao8.com', "");   }   }   

function setHomepage(){  // 设置首页   if (document.all){   document.body.style.behavior = 'url(#default#homepage)';   document.body.setHomePage('http://www.caidao8.com');   }else if (window.sidebar){   if (window.netscape){   try {   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   }catch (e) {   alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 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.caidao8.com');   }   }    </script>  </head>  <body>  <a href="javascript:setHomepage();" >首页</a>  

<a href="javascript:addCookie();">收藏"</a>  </body>  </html>
<html>
<head>
<script>
function addCookie(){  // 加入收藏夹
if (document.all){
window.external.addFavorite('http://www.caidao8.com', '财刀网');
}else if (window.sidebar){
window.sidebar.addPanel('财刀网', 'http://www.caidao8.com', "");
}
}
function setHomepage(){  // 设置首页
if (document.all){
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage('http://www.caidao8.com');
}else if (window.sidebar){
if (window.netscape){
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}catch (e) {
alert("该操作被浏览器拒绝,如果想启用该功能,请在地址栏内输入 about:config,然后将项 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.caidao8.com');
}
}
</script>
</head>
<body>
<a href="javascript:setHomepage();" >首页</a>
<a href="javascript:addCookie();">收藏"</a>
</body>
</html>

转载于:https://www.cnblogs.com/yuanlei347/archive/2010/11/18/1880700.html

兼容FireFox和IE8的设为首页和添加收藏相关推荐

  1. 完美兼容IE,chrome,ff的设为首页、加入收藏及保存到桌面js代码

    <script  type="text/javascript"> //设为首页 function SetHome(obj,url){     try{         ...

  2. 设为首页 加入收藏 html,[javascript]js设为首页和加入收藏夹代码

    我们见过很多网站的顶部都有这样的功能,设为首页和加入收藏的功能. 其实,这些功能的实现也都是js代码实现的,今天我为另一个网站添加了这样的代码.点击测试有效.代码如下. js代码: //tmac 设为 ...

  3. 如何实现设为首页,加入收藏的功能

    如何实现"设为首页","加入收藏"的功能 解决思路: 将指定URL设为首页的功能主要是依靠IE默认行为homePage的setHomePage方法,而将指定UR ...

  4. 网页制作 HTML设为首页和加入收藏_动力节点Java学院整理

    网页制作 HTML设为首页和加入收藏_动力节点Java学院整理 IE浏览器下如何实现"设为首页","加入收藏"的功能 解决思路: 将指定URL设为首页的功能主要 ...

  5. 设为首页、加入收藏 兼容代码

    一般写法: <a href="javascript:window.external.AddFavorite(window.location.href,document.title)&q ...

  6. MVC3.0 将网站设为首页和加为收藏的实现(IE/Firefox)

    设置为首页的方法为: <a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage( ...

  7. 很实用的 “设为首页”与“加入收藏”代码

    设置为首页的方法为: <a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage( ...

  8. 设为首页和加入收藏js

    /*加入收藏夹*/  function addfavorite(url,title)  {          try          {                  window.extern ...

  9. 网站设为首页,加入收藏夹

    <a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('URL');even ...

  10. IE,chrome,ff的设为首页、加入收藏及保存到桌面js实现

    声明:该文章转自https://blog.csdn.net/qq_29362889/article/details/52033793,原作者更详细 js 部分代码 <script type=&q ...

最新文章

  1. LeetCode Perfect Squares
  2. jpa取出mysql数组_java读取数据库数据,并将数据存入数组返回
  3. 一个列用render渲染的时候,如果列宽度不够,内容多出的部分会被隐藏,无法显示。这时需要一个鼠标滑过提示全部内容的tip功能。...
  4. Leetcode 之Evaluate Reverse Polish Notation(41)
  5. [转载]DEV控件:gridControl常用属性设置
  6. arouter跨module传递消息_利用ARouter实现组件间通信,解决子模块调用主模块问题...
  7. P2596 [ZJOI2006]书架 无旋treap 按照排名分裂
  8. markdown UML图
  9. HTML字符实体大全
  10. 值得收藏,分享3个的 Python 实战项目
  11. SLAM入门-相机成像原理与公式推导
  12. 太阳光轨迹软件_巧用虚拟天文馆软件Stellarium演示太阳周日视运动轨迹_贺志康...
  13. linux 命令无法Tab补全,命令参数无法补全
  14. matplotlib报错Line2D‘ object has no property ‘linestyle‘或‘linewidth‘
  15. springboot启动banner图片
  16. 【报错笔记】Vector for token xxx has 147 dimensions, but previously read vectors have 300 dimensions.
  17. 科学计算机统计说明书,科学计算器的使用方法
  18. bugku never give up
  19. 高性能超融合服务器,深信服高性能单路服务器aServer-R-1600超融合一体机
  20. vb6.0 类没有注册,查找具有 CLSID 的对象:{7EBDAAE0-8120-11CF-899F-00AA00688B10} 7EBDAAE1 7EBDAAE2

热门文章

  1. 【洛谷P5019+P1969+P3078】道路铺设(暴力模拟/差分)
  2. java spite截取_Java內功心法,行為型設計模式
  3. 计算机初级技能词,计算机领域英语常用词汇初级.doc
  4. MLOps- 吴恩达Andrew Ng Overview of the ML Lifecycle and Deployment Week1 部署深度学习模型model 实现作业
  5. linux怎么卸载软件 apt,linux安装和卸载软件:sudo apt-get install(remove)
  6. Evolved Transformer
  7. Ubuntu16.04安装python3.6
  8. How to use neural network to realize logic 'and' and 'or'?
  9. 安装Ubuntu18
  10. 【ACM ICPC 2011–2012, Northeastern European Regional Contest】Interactive Permutation Guessing【交互题】