Fixing IE8 mystery error KB927917

While testing some updates to one of our Facebook applications today, I ran into an odd error message on IE8.  The error message mentioned KB927917, and is caused by trying to modify the DOM before it is built.  At first, I was confused, because the app is not modifying the DOM at all, its a redirect that is part of the authentication step.  The culprit code was something like:

<script type="text/javascript">
top.location.href = 'http://example.com/foo/';
</script>

This was working, without warnings, in Chrome, Firefox, and IE7.  To prevent IE8 from complaining, the redirect should happen after the page is done loading.

<script type="text/javascript">
window.onload = function() {
    top.location.href = 'http://example.com/foo/';
};
</div>
</script>

Related Items

If you're using Internet Explorer, or are forced to use it at work, you should seriously consider switching browsers...
Scott Berkun, who designed and worked on the development of Microsoft's Internet Explorer versions 1 to 5, explains why...
It seems Microsoft is trying to stem the tide of users ditching the security hazard that is Internet Explorer for...
According to broadband reports, phishing scams which exploit Microsoft Internet Explorer's bug that allows scam artists...
Count me in this group of developers who wish Microsoft would fix their broken Internet Explorer. I also wish all you...
One of the joys of testing with IE8 is the added google time that I get to spend hunting down bugs and solutions. If...