我是具有IE7兼容模式和HTML5的奇怪问题。

症状:直接进入我的主页,使用PHP可以检测到IE7。击中表单提交按钮后,单击返回后按钮,即使仍处于兼容模式,也不再检测为IE7。必须刷新或重新加载以再次检测IE7。

我该怎么做才能使这更强大?请不要说要使用get_browser和browscap。我不希望保留在那种浏览器上。

在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]-->
.

击中后按钮仍然会做同样的事情。

编辑:男人....我想我有一些严重的机器问题。Windows Update后,带窗口的框必须已拧紧。对不起这个疯狂的东西。在另一台没有运行Windows更新的机器上工作。

有帮助吗?

解决方案

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