返回博客

IE 兼容性问题及解决方法:在 head 中添加 meta 信息

本文介绍了解决 IE 浏览器兼容性问题的方法,特别是 IE 浏览器使用 IE5 内核加载网页的问题。通过在 HTML 的 `<head>` 中添加`<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">`元数据标签,可以强制 IE 浏览器使用最新模式渲染页面,从而解决兼容性问题。

Mt.r
|

今天我好不容易做好了 IE 的兼容,然后代码也能跑通,但是在另外一台电脑上就跑不起来了,是什么情况呢?

查了半天,是因为我自己 devtool 中,手动指定了 IE 版本号到 IE11,默认情况下,IE 浏览器竟然会用 IE5 去加载网页,恐怖如斯

查了资料,发现需要在 head 中插入这样的代码 <meta http-equiv="X-UA-Compatible" content="ie=edge">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Document</title>
</head>