1

I have Googled for a JavaScript that sets the current page to your startpage. But all I can find is some old script for IE 5 and up.

<FORM>
<INPUT TYPE="button" VALUE="Make This Site Your Home Page" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage('Page URL beginning with http:// here');">
</FORM>

They only seem to work in IE and they also seem to be inline.

I'd like one in my script file and one that works in all browsers.

CraigTeegarden
  • 8,173
  • 8
  • 38
  • 43
patad
  • 9,364
  • 11
  • 38
  • 44
  • 1
    It doesn't look like there is such a script that works in all browsers. People don't like their homepage being reset, and if it were possible with Javascript, it would be exploited and abused. – Fosco Aug 06 '10 at 19:05
  • 1
    Most browsers consider this to be a security threat. Because you could set their browser's home page to a phishing site. – Jack B Nimble Aug 06 '10 at 19:05
  • Thanks. That totally makes sense. Guess I won't find one hey.. – patad Aug 06 '10 at 19:08
  • 1
    If enduser likes the site s/he will make it homepage anyway. Pushing it to the user's throat will likely only scare them and never come back. – BalusC Aug 06 '10 at 19:17

2 Answers2

1

Id like one in my script file

That shouldn't be a problem. Add

document.getElementById("link_id").style.behavior = .......

to your script file (also giving the link an ID).

and one that works in all browsers.

That is not possible. (Thankfully, in my opinion.) I think there was a workaround for Firefox, but none for the other browsers.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • Thats what I thought. Thanks for that. Time to tell my client it's not gonna happen ;-) – patad Aug 06 '10 at 19:10
0

The answers given in this duplicate post cover it best:

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

In essence: Just don't.

If you feel you have to: provide instructions, enable users to do it manually.

Community
  • 1
  • 1
Frank N
  • 9,625
  • 4
  • 80
  • 110