Question

If I use header( 'Location: http://www.example.com/test.php' ); to send users to test.php. I noticed this in IE9 console:

HTML1113: Document mode restart from Quirks to IE9 Standards 
test.php

HTML1115: X-UA-Compatible META tag ('IE=9') ignored because document mode is already finalized. 
test.php

This completely mess up my code on test.php.

Question

I am already using <!DOCTYPE html><html><head><meta http-equiv="X-UA-Compatible" content="IE=9"> but I am guessing using PHP header() to redirect causes problems with that.

Is there a way to stop IE9 from going into quirks mode when using PHP header() to redirect users?

Additional Info

It went to Quirks mode and the back to Standard mode, which seems to break my code on the page.

The user starts in test.php, click submit on a captcha, which POST to verify.php - which has <?php if (condition){ change some session variables; header(etc); exit();} ?> right at the beginning.

Was it helpful?

Solution

Using php to echo a meta refresh redirect instead of the php header appears to have fixed the problem. All the code works, there is no going to quirks mode and back to IE9 mode, and the meta does not get ignored.

Additional Info

I spoke to a software/web programmer personally and he doesn't know offhand why this error occurred. However, his opinion is that if meta refresh works instead of php headers, there is no problem using it instead.

OTHER TIPS

I was thinking about this a bit more , and had a thought:

IE9 will jump into quirks mode for any page the doesn't start with a <!DOCTYPE>.

The header(...) redirect can still have further output after it, which will be seen as a page.

So... if there is any output after the header() is sent, and that output does not start with a valid <!DOCTYPE>, IE9 could jump into quirks mode.

In PHP, this could happen if the code carries on running after the header() call, and something in the subsequent code produces output of some sort.

If this is what is happening, and you don't need the code to keep running after the redirect (which would be unusual) then adding a call to die(); immediately after the header() should fix it.

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top