如何让旧版IE浏览器认识HTML5元素

时间:2024-03-29 09:34:14

<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 < ![endif]-->

解读:

<!--[if lt IE 9]>

<script type="text/javascript">

var e=("abbr,article,aside,audio,canvas,datalist,details,"+ "figure,footer,header,hgroup,mark,menu,meter,nav,output,"+ "progress,section,time,video").split(',');

for(var i=0;i<e .length;i++){

document.createElement(e[i]);
}

</script>

< ![endif]-->

请看如下的例子:

<!DOCTYPE HTML>

<html lang="en">

<head>

<meta
http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>unknown
elements</title><style> article{display:block;border:1px solid
red}</style></meta></head><body><article>
<h1>welcome to feimos's blog</h1> <p>This is
your <span>first time to visit this webSite.</span></p></article>

</body>

</html>