【发布时间】:2019-11-04 13:10:05
【问题描述】:
我正在开发一个网站。我们现在不想浪费时间或资源来优化 Internet Explorer。如何检测页面是否已在 IE 中打开,然后有条件地呈现浏览器不支持的页面而不是实际的主页。
我考虑过 html 条件 cmets,但从 IE10 开始不再支持它们。
【问题讨论】:
标签: internet-explorer cross-browser feature-detection
我正在开发一个网站。我们现在不想浪费时间或资源来优化 Internet Explorer。如何检测页面是否已在 IE 中打开,然后有条件地呈现浏览器不支持的页面而不是实际的主页。
我考虑过 html 条件 cmets,但从 IE10 开始不再支持它们。
【问题讨论】:
标签: internet-explorer cross-browser feature-detection
您可以使用window.navigator.userAgent 来检测IE 浏览器。您可以参考下面的 JavaScript 代码:
var ua = window.navigator.userAgent;
var trident = ua.indexOf('Trident/');
if (trident > 0) {
console.log('Your browser is IE');
}
【讨论】: