仅在使用Internet Explorer 10+时提醒消息

问题描述 投票:0回答:2

我管理的网站有100多页,最近更新为使用Bootstrap-4和Flexbox。问题是,通过Internet Explorer 10+查看时,许多页面都会中断。我们希望在模式中弹出消息,建议用户升级其浏览器,而不是重写代码来定位Internet Explorer。但是,如果用户使用IE查看我们的网站,我只希望显示此消息。由于在IE10中禁用了条件注释,因此它们不是一种选择。我搜索了SO和谷歌寻找答案,但没有运气。

internet-explorer browser alert
2个回答
0
投票

尝试使用下面的代码进行测试可以帮助您识别IE 10版本。

<!DOCTYPE html>
<html>
<head>
	<title>Page Title</title>
	<script>
	if (navigator.appVersion.indexOf("MSIE 10") !== -1)
{
    window.alert('This is IE 10');
}
	</script>
</head>
<body>
	sample text
</body>
</html>

IE 10中的输出:

enter image description here


0
投票

我发现@supports (display: grid) {对这个问题很有效,并且对于不支持flexbox的旧浏览器有一个后备。

© www.soinside.com 2019 - 2024. All rights reserved.