質問

IE7互換モードとHTML5の奇妙な問題を抱えています。

症状:PHPを使用して、私のホームページに直接進んでいて、それがIE7であることを検出できます。フォーム送信ボタンを押した後、戻り戻るボタンをクリックすると、互換モードのままでもIE7として検出されなくなりました。再びIE7として検出するために更新またはリロードする必要があります。

これをより堅牢にするために私は何ができますか?get_browserとbrowscapを使うつもりはありません。そのbookscap.iniを維持し続けました。

HTMLヘッド:

<?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; ?>
.

更新:

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

js.js行を:

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

はまだ戻って戻るときに同じことをします。

編集:man ....私は深刻なマシンの問題があると思います。Windowsの更新後にWindowsのボックスがネジアップされている必要があります。このクレイジーなものをごめんね。Windowsの更新がまだRANされていない別のマシンでうまく機能します。

役に立ちましたか?

解決

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.

他のヒント

As @tradyblix said, you can do this client side. They're called conditional comments.

If you have to do it in the PHP, I would use strpos().

$ua = $_SERVER['HTTP_USER_AGENT'];
if (stripos($ua, 'MSIE') === false || stripos($ua, 'MSIE 9') !== false)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top