0

I want a jquery code to set my current page as a home page for all browsers. I have tried this code but in vain

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

as well as I tried also this

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

These code snippets are available on internet but these threads are old. and according to this thread its not possible. any one tried this recently?

Community
  • 1
  • 1
Billz
  • 1,067
  • 6
  • 25
  • 57
  • No. Just: ***No***. What on earth do you feel gives you the right to do this, and mess up *my* browser with *your* website? No, it's not possible; and thankfully so. – David Thomas Nov 26 '14 at 07:41

2 Answers2

2

Luckily you can't do this anymore > the old IE style of setting the homepage via click was an enfant terrible amongst the ideas of the era. The phrase HomepageHijacking isn't picked because "we all ment it well".

Not only to mention the fact all modern browser support multi-tab-multi-homepage methods it would be really annoying (or downright scary) if you could adjust the homepage on all my 4 test-browsers in one click.

Leon
  • 919
  • 6
  • 21
0

There is always a security issue that comes with this script, for which the browsers prevents directly handling changing of Homepage.

Where as, you can try this approach-

<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

Hope it helps!


After more research on this, I found this answer-

You can't do it in FF because of security. Check out this article. Your user would have to change the signed.applets.codebase_principal_support setting to false. Probably not something that is worth counting on.

Check : How can I set default homepage in FF and Chrome via javascript?

Community
  • 1
  • 1
bozzmob
  • 12,364
  • 16
  • 50
  • 73