phphtmlie-compatibility-mode

Why does IE7 compatibility back button php can't detect as IE7?


I am having weird issues with IE7 Compatibility mode and HTML5.

Symptoms: Going directly to my homepage, using PHP can detect that it is IE7. After hitting a form submit button, and clicking the return back button, it no longer detects as IE7 even while still in compatibility mode. Must be refresh or reloaded to detect as IE7 again.

What can I do to make this more robust? Please don't say to use get_browser and browscap. I do not wish to keep maintain on that browscap.ini.

in the html head:

<?php 
    /**
    *   IE 7 has trouble with jscrollpane, so disable for all IE except for 9 which works just fine.
    */ 
    $getBrowser = $_SERVER['HTTP_USER_AGENT']; 
    if( (!stristr($getBrowser,'MSIE')) || stristr($getBrowser,'MSIE 9')):
?>
<script src="jquery/jquery.mousewheel.js"></script>
<link  rel="stylesheet" href="styles/jquery.jscrollpane.css" />
<script src="jquery/jquery.jscrollpane.min.js"></script>
<script  src="jquery/js.js"></script>
<?php endif; ?>

Updated:

$getBrowser = $_SERVER['HTTP_USER_AGENT']; 
        if( stristr($getBrowser,'MSIE') === false)

Relocated js.js line to:

<!--[if IE 9 ]>
    <script  src="jquery/js.js"></script>
<![endif]-->

Still does the same thing when hitting back button.

Edit: Man.... I guess I am having some serious machine problems. The box with windows must have been screwed up after the windows update. Sorry for this crazy stuff. Works fine on another machine that has not ran windows update yet.


Solution

  • I don't have IE9 so I can't try it but can't you do something like this and place it on the <head>:

    <!--[if IE 9]>
         // your includes here
    <![endif]-->
    

    Not sure if it matters to you to still see the script tags included in the source but at least it won't execute them unless the check was satisfied.