为所有浏览器制作主页

make homepage for all browsers

本文关键字:主页 浏览器      更新时间:2023-09-26

我想要一个jquery代码将我的当前页面设置为所有浏览器的主页。我试过这段代码,但徒劳无功

<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://dynamicdrive.com');">Click here to make Dynamic Drive your default homepage</a>

以及我也尝试了这个

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

代码片段可以在互联网上找到,但这些线程是旧的。 根据这个线程,这是不可能的。 最近有人尝试过吗?

幸运的是,

你不能再这样做了,>通过点击设置主页的旧IE风格在那个时代的想法中是一个可怕的孩子。选择"主页劫持"一词不是因为"我们都很好"。

不仅要提到所有现代浏览器都支持多标签多主页方法的事实,如果您可以在我的所有 4 个测试浏览器上一键调整主页,那将非常烦人(或彻头彻尾的可怕)。

此脚本始终存在安全问题,浏览器会阻止直接处理主页的更改。

在哪里,你可以试试这种方法——

<a href="#" 
 onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://dynamicdrive.com');">
   Click here to make Dynamic Drive your default homepage
</a>

http://www.dynamicdrive.com/dynamicindex9/addhome.htm

希望对您有所帮助!


对此进行了进一步的研究,我找到了这个答案——

由于安全性的原因,您无法在FF中执行此操作。看看这篇文章。用户必须将signed.applets.codebase_principal_support设置更改为 false。可能不值得指望。

检查:如何通过javascript在FF和Chrome中设置默认主页?