While I was testing my web apps in the new Internet Explorer 7 I discovered that sometimes a page is not rendered properly after a refresh. After some testing I realized that somehow the browser is randomly showing a blank (white) page when I hit the reload button a couple of times. The interesting thing was that when I viewed the sourcecode everything was there but the page wasn’t displayed at all. I did some research and found the reasons/solutions for it.
Problem: IE7 displays a blank page after doing some refresh’s.
Environment: classic ASP application, WIN XP Pro, IIS 5.1
Reproduction: create the following page and refresh it a couple times:
- <% response.buffer = true %>
- <html>
- <head></head>
- <body>
- <script src="somescript.js"/>
- test, test
- </body>
- </html>
- <% response.flush() %>
Solution: There are two points I’ve found out…
- check if you have any scripts (script src=”..”/> loaded within the -tag. If yes then you’ll have to move them to the body and everything should work. As far as I remember the W3C says “This element may appear any number of times in the HEAD or BODY of an HTML document.” [W3C Script element] Anyway
- if you are using classic ASP you also need to assure that you don’t flush the response at the end of your page. Remove the response.flush() line and your apps should work fine.
Okay now lets move on to the details. I was searching the web and there are hardly any resources for this bug yet. I found a post about it in the MSDN forums (IE 7 display blank page on refresh when viewing session enabled PHP pages served from IIS 6!!) where a guy experienced the same in his PHP apps and I’ve found a post by a guy called Kerry D. Wong who blogged about a similar issue (Meta Refresh Bug in IE7?) but in my case it did not solved the problem but i came closer.
I have a dozen of apps written in classic ASP and all of them display a blank page from time to time now. Moving the javascript references to the body (solution of the PHP problem above) did not solved the problem in my case but when I removed them completely then everything worked fine. So the bahavior is similar somehow. I played around and finally discovered that it has to do with the response.flush(). When I got rid of that line everything was fine and like in the old days… buuut MS should pay for the time I have spent on this.
Ahm, where should I send the invoice?
As there aren’t almost any resources about this bug on the web yet I cannot really tell you the detailed reasons for it but I am sure they will pop up soon. I guess it has something to do with the keep-alive requests. There is a remark about the response.flush() method in the MSDN documentation which says: “If the Flush method is called on an ASP page, the server does not honor Keep-Alive requests for that page.”.
Your post put me on the right track to solving this - thanks.
I was unable to see any pages within a pretty standard JSP web app that contained a (properly formed!) non-empty script element, e.g. within the element of an xhtml-doctype page. I just kept getting a blank page in both IE6 & IE7 although the page had loaded and the source was viewable. Putting the script element into the did nothing - the only way round it was to turn it into an empty-body HTML4 type tag, e.g. .
Just another example of poor IE standards compliance I guess, and really annoying, not only to track down but because of the solution!!
I had this issue as well, but I think Microsoft have picked up on it. Because I upgraded to IE8 and the problem had gone, it was a bug more than anything else.
Good post dude.