I can't get html5shiv working?

蓝咒 提交于 2020-01-05 13:55:24

问题


For some reason, it just won't work for me in IE at all. It's in the head tag. I added the CSS. Nothing.

<!--[if lt IE 9]>
<script type="text/javascript" src="scripts/html5shiv.js"></script>
<![endif]-->
<script type="text/javascript">
    $(function() {
        document.createElement("header");
    });

<style>header,nav,article,footer,section,aside,figure,figcaption{display:block}</style>

Any help would be appreciated. Thanks.


回答1:


You probably want to append that HEADER element to the DOM:

var elem = document.createElement( 'header' );
elem.innerHTML = 'The header';
document.body.appendChild( elem );

Live demo: http://jsfiddle.net/dW9Ak/




回答2:


You might also want to close that script tag too. Although as Šime Vidas says, you do also need to append the created element to the DOM.

Also, are you testing this in IE itself, or in IE Tester? I spent ages trying to get html5shiv to work in IE7 in IE Tester, only to find that it seems to be working ok in IE7 itself. In the process, I discovered that you can make IE8 and IE9 render as earlier versions of IE using an HTML tag, like so:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7;">

More info about the above meta tag here.



来源:https://stackoverflow.com/questions/11249287/i-cant-get-html5shiv-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!