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.
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.
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.
精彩评论