• 设为主页的js方法,兼容ie,firefox


    一般在ie下面 

    <a  href="#" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.reworlds.com')">设置为主页</a>

    如果是firefox 则要自己写setHomePage()函数了(不推荐,一般谁也不去改这个设置,兼容ie就好)

    要使用脚本在firefox下设置主页,首先必须确认在浏览器的“about:config”中,把
      signed.applets.codebase_principal_support
      设置成true

    function setHomePage(a)
      {
      
       if (document.all)
       {
       document.body.style.behavior='url(#default#homepage)';
       document.body.setHomePage('http://www.reworlds.com');
       }
       else if (window.sidebar)
       {
       if(window.netscape)
       {
       try
       {
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
       }
       catch(e)
       {
       alert("this action was aviod by your browser,if you want to enable,please enter about:config in your address line,and change the value of signed.applets.codebase_principal_support to true");
       }
       }
       var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
       prefs.setCharPref('browser.startup.homepage','http://www.reworlds.com');
       }
      }

  • 相关阅读:
    C# 控制反转(IOC: Inverse Of Control) & 依赖注入(DI: Independence Inject)
    英语常见短语汇总001
    ASP.Net Web.config 中引用外部config文件
    CSS样式汇总
    RSA非对称加密算法
    排序算法【2】——快速排序
    cmake引入boost
    boost之algorithm
    tar命令
    欧拉定理
  • 原文地址:https://www.cnblogs.com/ytmf007/p/1640360.html
Copyright © 2020-2023  润新知