setHomePage函数有替代方法吗? [英] are there any alternative to setHomePage function?

查看:69
本文介绍了setHomePage函数有替代方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在浏览器中设置主页,但是setHomePage仅在IE中有效.

I need to set the home page in browser, but setHomePage works only in IE.

有什么方法可以做到吗? (我找不到这样的结果)

Are there any method to do it? (i can't find such results)

非常感谢

推荐答案

Personnaly,我在Google上发现了这一点:

Personnaly, I found that with Google:

如何通过Java脚本为mozilla firefox设置主页?

嗨thuypv

Hi thuypv

根据我的经验,我们无法设置Firefox的主页,如果浏览器将signed.applets.codebase_principal_support设置为false,我们唯一能做的就是提醒用户更改设置.您可以针对IE和Firefox尝试以下代码:

Based on my experience, we cannot set the home page of Firefox, if the browser set signed.applets.codebase_principal_support to false, the only thing we can do is remind use to change the setting. You can try the following code, both for IE and Firefox:

<script language="javascript">
function setHomepage()
{
  if (document.all)
  {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage('http://www.asp.net/130.aspx');         
  }
  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.asp.net/130.aspx');
  }
}
</script>
<input type="button" value="set home page" onclick="setHomepage();" />

如果我误解了您的问题,请随时告诉我.

If I’ve misunderstood your problem, please feel free to let me know.

谢谢.

这篇关于setHomePage函数有替代方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆