有条件的注释来定位Windows Phone 7上的Internet Explorer 9

5

问题

条件注释,例如

<!--[if IEMobile]>
    <p>Welcome to Internet Explorer Mobile.</p>
<![endif]-->
<![if !IEMobile]>
    <p>All other browsers</p>
<![endif]>

在Windows Phone 7上不起作用!或者至少在我的手机上不起作用。


问题

有人知道如何使用这些注释吗?并且之前测试过吗?IE 9在WP7上是否支持这个?

2个回答

1

非常抱歉,以下内容在Mango之前可以使用。

<!--[if IEMobile 7]>
    <p>欢迎使用Internet Explorer Mobile。</p>
<![endif]-->
<![if !IEMobile 7]>
    <p>所有其他浏览器</p>
<![endif]>

看起来现在必须使用JAvaScript并检查UserAgent以查看Windows Phone OS 7或Windows Phone OS 7.5是否已列出...唯一的方法。


谢谢你的回答,但是这个方法并不起作用。你测试过吗? - neeKo
你是在你的设备上测试还是模拟器上? - MyKuLLSKI

1

尝试使用gte(以防它将您的手机视为7.5)

<!--[if gte IEMobile 7]>
<p>Welcome to Internet Explorer Mobile.</p>
<![endif]-->
<![if !IEMobile 7]>
<p>All other browsers</p>
<![endif]>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接