Search code examples
phpinternet-explorerquirks-mode

PHP Header() redirect triggers IE9 Quirk mode


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.


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.