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');
       }
      }

  • 相关阅读:
    高效能人士懂得忽视,知道怎样说“不”
    CheckBoxPreference组件
    SQL基础--&gt; 约束(CONSTRAINT)
    html5--6-7 CSS选择器4
    html5--6-6 CSS选择器3
    html5--6-5 CSS选择器2
    html5--6-4 CSS选择器
    html5--6-3 CSS语法2
    html5--6-2 CSS语法
    html5--6-1 引入外部样式表
  • 原文地址:https://www.cnblogs.com/ytmf007/p/1640360.html
Copyright © 2011-2022 走看看