简体   繁体   中英

Set default home page in JavaScript

如何创建链接以将用户的主页设置为我的URL?

As some people have already answered, it used to be possible in internet explorer (prior to IE 7 I believe, could be wrong though) using something similar to

document.setHomePage('www.example.com');

I don't think any browser supports it anymore though. However, I would definitely try to convince you to do otherwise. Most people won't like having their settings automatically changed, even if it's triggered by a mouse click or other action. It's also quite likely that overzealous 'protection' programs will jump all over it and stamp it as a malicious attack.

As far as I know it's just possible in Internet Explorer

Make my Page your
<a href="javascript:history.go(0)" onClick="this.style.behavior='url(#default#homepage)';
 this.setHomePage('http://www.test.de');">Startpage</a>.

I assume you mean put a link in your page to make it the browser homepage? In IE you can do something like:

this.setHomePage('http://www.mysite.com');

I don't think that works in Firefox though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM