最后一个用户代理字符串覆盖了前一个字符串

时间:2017-04-11 18:58:42

标签: user-agent

我已将此脚本包含在Rog.ie(http://archive.is/Zf3Pd

<script>
var b = document.documentElement;
b.setAttribute('data-useragent', navigator.userAgent);
b.setAttribute('data-platform', navigator.platform );
b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
</script>

以下数据使用者(6,3是Windows 8.1和6.1是Windows 7):

html[data-useragent*='MSIE'][data-platform='Windows NT 6.3']
.example {
color: black;
}
html[data-useragent*='MSIE'][data-platform='Windows NT 6.1']
.example {
color: white;
}

然而,无论我是在Windows 8.1还是7上,它都只适用于底层使用者,即上面的例子中颜色为白色,但如果反转如下,则颜色为黑色。

html[data-useragent*='MSIE'][data-platform='Windows NT 6.1']
.example {
color: white;
}

html[data-useragent*='MSIE'][data-platform='Windows NT 6.3']
.example {
color: black;
}

我正在通过Dreamweaver开发的笔记本电脑浏览器上测试这些用户代理,所以我还没有在服务器上进行测试。数据用户代理代码是否无法正常工作,因为该网站尚未在服务器上或我做错了什么?

谢谢

0 个答案:

没有答案
相关问题