一行代码轻松搞定各种IE兼容问题,IE6,IE7,IE8,IE9,IE10 - trigkit4
在网站开发中不免因为各种兼容问题苦恼,针对兼容问题,其实IE给出了解决方案Google也给出了解决方案百度也应用了这种方案去解决IE的兼容问题?
百度源代码如下:
<!Doctype html>
<html xmlns=http://www.w3.org/1999/xhtml xmlns:bd=http://www.baidu.com/2010/xbdml>
<head>
<meta http-equiv=Content-Type content=“text/html;charset=utf-8″>
<meta http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<title>百度一下,你就知道 </title>
<script>
var wpo={start:new Date*1,pid:109,page:‘superpage’}
</script>
<meta http-equiv=X-UA-Compatible content=IE=EmulateIE7>
可以打开百度,右键查看源码看下!我们可以看下文件头是否存在这样一行代码,这句话的意思是强制使用IE7模式来解析网页代码!
在这里送上几种IE使用模式:
1.强制使用IE5模式来解析
<meta http-equiv=“X-UA-Compatible” content=“IE=5″>
2.强制使用IE6模式来解析
<meta http-equiv=“X-UA-Compatible” content=“IE=6″>
3.强制使用IE7模式来解析的两种方式
<meta http-equiv=“X-UA-Compatible” content=“IE=EmulateIE7″>
<meta http-equiv=“X-UA-Compatible” content=“IE=7″>
- 强制使用IE8模式来解析
<meta http-equiv=“X-UA-Compatible” content=“IE=8″>
- Google Chrome Frame也可以让IE用上Chrome的引擎:
<meta http-equiv=“X-UA-Compatible” content=“chrome=1″/>
6.如果一个特定版本的IE支持所要求的兼容性模式多于一种,如下代码就是IE5和IE8两种模式:
<meta http-equiv=“X-UA-Compatible” content=“IE=5; IE=8″/>