zoukankan      html  css  js  c++  java
  • 设为主页的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');
       }
      }

  • 相关阅读:
    composer国内镜像配置
    composer.json和composer.lock作用
    工厂模式(描述语言PHP)
    PHP后期静态绑定
    js事件冒泡和事件捕获
    去帮助别人,并接受别人的帮助
    平静,问题本身也是问题
    总是被欲望折磨的我
    习惯产生力量
    秦岭野生动物园
  • 原文地址:https://www.cnblogs.com/ytmf007/p/1640360.html
Copyright © 2011-2022 走看看