WWW FAQs: How do I set the user's home page with JavaScript?

2007-01-29: In Internet Explorer 6.0 and earlier, it was possible to change the user's home page with JavaScript. Other browsers, particularly Firefox, never offered this feature. Microsoft has removed this feature in Internet Explorer 7.0.

How It Used To Work

Until Internet Explorer 7.0, it was possible to do it via JavaScript code, like this:


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

But this is no longer permitted in Internet Explorer 7.0. Since Internet Explorer 7.0 is being "pushed" out to all windows XP computers via Windows Update, this is no longer considered a practical technique.

The Best Workaround Today

The best workaround is to give your users instructions on how to manually set the home page. The following code uses conditional comments to give Internet Explorer 7.0 instructions to Internet Explorer users and generic instructions to non-Internet Explorer users:


<!--[if IE]>
Click on the "down" arrow just to the right of the "house" icon in
your Internet Explorer toolbar and choose "Add or Change Home Page."
Then click on "Use this webpage as your only home page" or
"Add this webpage to your home page tabs," depending on
your preference.
<![endif]-->
<![if !IE]>
To make this page your home page, just drag the icon to the left of the
URL in your location bar onto the "Home" icon in the "house" icon in
your toolbar. Some browsers do this differently. You can always set your
home page through the preferences of your browser.
<![endif]>

Yes, it's frustrating that you can't do this automatically anymore, but keep in mind that most users don't like the feeling that a web page is "trying to take over." Spyware and adware have made users very hostile to "greedy" websites that try to permanently alter the browsing experience.

Share |

Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.

Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!


Follow us on Twitter | Contact Us

Copyright 1994-2014 Boutell.Com, Inc. All Rights Reserved.