- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Internet Explorer 10+ 不再支持条件注释。好的,太棒了。
这是我需要的:
(if this browser is Internet Explorer of ANY version) {
//apply IE CSS class here
} else {
//apply non IE CSS class here
}
我已经尝试了所有我能在互联网上找到的东西,但在不影响所有浏览器的情况下没有任何效果。例如,以下代码不起作用,因为“浏览器不是 IE 打印在所有浏览器上:
<!DOCTYPE html>
<!--[if lte IE 8]><html class="ie8 no-js" lang="en">IE 8-10<![endif]-->
<!--[if lte IE 10]><html class="ie10 no-js" lang="en">ID 8-<![endif]-->
<script>
var isIE = (navigator.userAgent.indexOf("MSIE") != -1);
if (!isIE) {
document.write("<html class='not-ie no-js' lang='en'>");
document.write("Browser is nott IE.");
}
</script>
最佳答案
navigator.sayswho= (function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE '+(tem[1] || '');
}
if(M[1]=== 'Chrome'){
tem= ua.match(/\bOPR\/(\d+)/)
if(tem!= null) return 'Opera '+tem[1];
}
M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
return M.join(' ');
})();
该代码将返回您浏览器的名称。您可以根据返回值执行条件语句。
感谢 u/kennebec 提供脚本。效果很好。
关于javascript - 后条件注释时代的浏览器检测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24400701/
我想通过添加一个带有 transition = 0s 的类但更改颜色来使用 jQuery 运行 CSS 动画,然后立即删除该类(使用原始 transition = 2s)它逐渐变为原始颜色。 下面是我
最近两年,互联网+的概念可谓十分火爆。所谓“互联网+”,其实质就是把互联网大平台和各行各业进行有机结合,建立一个新的商业生态,对于传统企业来说,互联网+的第一步就是有一个企业网站,将自己推广出去
每天我都更喜欢 Postgres,今天我发现了函数“age”。它不仅选择年份,还选择月份和日期。太棒了! 46 years 10 mons 18 days 现在我想知道是否有一个函数可以定义“年”、“
我正在 秒 内从服务器接收数据,我想将其转换为最新数据。 但我收到的秒数不是自 UNIX 纪元 01/01/1970 以来,而是 01/01/2000。 通常我会使用: SimpleDateForma
如果在 matlab 中使用可变时间步长求解器,例如 ODE45 - 我将为输出定义一个时间跨度,即 times = [0 50],matlab 将返回不同时间步长的结果介于 0 和 50 之间。 但
因此,System.currentTimeMillis 以 UTC 时区返回毫秒。 DateTime.getmillis 是否与我所知道的几乎所有图书馆都一样,因为纪元总是在 UTC 中? joda-
Hadoop 2.0 引入了 YARN,取代了 Job Tracker 和 Task Tracker 的任务。 YARN 由资源管理器(调度器、应用程序管理器...)、节点管理器和应用程序管理器组成。
在 ViewModel 和 one activity multiple fragments 概念时代,Activity 与 Fragment 中放置 Toasts、Snackbars 有什么建议。 很
许多 Android 讨论都集中在(显然是著名的)Fingerpaint 示例上: https://stackoverflow.com/a/16650524/294884 我从哪里得到它,与 Andr
在(最终)向我的 Facebook 应用程序添加一些分析并意识到英语在我的用户语言列表中排名靠后后,我开始研究 official docs on internationalization . 但是,文
我是一名优秀的程序员,十分优秀!