views:

2703

answers:

8

Hi!

I have a code that works only in IE anb I was looking for something similar in FF and Chrome to set user's default homepage through a link 'click here to make this site your default homepage', but so far I didn't find anything.

Does anyone know how to do this?

Thanks!!

+1  A: 

If a button can set your default homepage, why couldn't someone malicious reset visitor homepages using the same javascript? This is why such a function does not exist on well behaved browsers.

CookieOfFortune
Because even IE asks the user for confirmation.
grawity
+5  A: 

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.

Joseph
+2  A: 

Use to be possible with this lovely snippet.

document.setHomePage("http://www.mywebsite.com/");

Shockingly, it was only supported by IE, and in IE7 it was discontinued.

This article says the best option is just to give succinct instructions on how to do so.

altCognito
+9  A: 

What you're asking for is generally considered very annoying page behavior and, therefore, isn't widely supported.

A better UX (User Experience) choice is to give a small set of "how-to" instructions on how the users can make your page their homepage in their respective browsers. Give the user the choice!

Justin Niessner
Especially because links that only work in a particular browser are annoying.
grawity
A: 

Thanks everyone!! I think I will remove this link for my project! :-)

AndreMiranda
A: 

I Have found one script which will work both ie & Mozila. But won't work in opera & chrome.

Write below function inside javascript tag

<script type="text/javascript">
function setHomepage()
{
 if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
  document.body.setHomePage('http://www.kerala.in');

    }
    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.kerala.in');
 }
}
</script>

then Call this function setHomepage() on click of button.

And Opera? And Webkit/Chrome/Safari? It stays the same. Don't do this, enable your user so that he can do it himself.
Boldewyn
Sorry if this sounded rude. I just saw, that this is your first answer. Don't let yourself get discouraged by someone like me ;-)
Boldewyn
You can format text as code (for better readability) by indenting a row 4 spaces.
nikc
A: 

Please forgive if it's not suit your expectation.

I Have found one script which will work both ie & Mozila. But won't work in opera & chrome.

Write below function inside javascript tag

function setHomepage()

{

if (document.all)

 { 

   document.body.style.behavior='url(#default#homepage)';

   document.body.setHomePage('http://www.kerala.in');
 }
 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.kerala.in');

  }

}

Joby Mavelikara
A: 
ff.exterNL.setAsHomePage('Page title');
Mbarry