• 让 ie6 支持html5


    引用:http://www.enet.com.cn/article/2011/0418/A20110418849475.shtml

    让IE(包括IE6)支持HTML5元素,我们需要在HTML头部添加以下JavaScript,这是一个简单的document.createElement声明,利用条件注释针对IE来调用这个js文件。Opera,FireFox等其他非IE浏览器就会忽视这段代码,也不会存在http请求。

    <!–[if IE]>
    <script src=”http://html5shiv.googlecode.com/svn/trunk/html5.js”></script>
    <![endif]–>

    上面这段代码仅会在IE浏览器下运行,还有一点需要注意,在页面中调用html5.js文件必须添加在页面的head元素内,因为IE浏览器必须在元素解析前知道这个元素,所以这个js文件不能在页面底部调用。

    这个html5的js文件是作者把他放在Google code project上提供给大家可以直接调用的,当然,如果觉得这样会影响你的网页打开速度,你可以把html5的js文件直接下载下来让后上传到自己的服务器单独调用。

    以下是html5的js文件中的代码:

    (function(){if(!/*@cc_on!@*/0)return;var e = “abbr,article,aside,audio,canvas,datalist,details,dialog,
    eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,
    output,progress,section,
    time,video”.split(’,'),i=e.length;while(i–){document.createElement(e[i])}})()

    除了在网页中调用包含以上代码的js文件来让IE浏览器支持HTML5元素以外,你也可以以下面这种方式把代码直接添加到网页中。

    <!–[if IE]>
    <script>
    (function(){if(!/*@cc_on!@*/0)return;var e = “abbr,article,aside,audio,canvas,datalist,details,dialog,
    eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,
    output,progress,section,
    time,video”.split(’,'),i=e.length;while(i–){document.createElement(e[i])}})()
    </script>
    <![endif]–>

  • 相关阅读:
    什么是前后端分离?
    Ubuntu修改时区和更新时间
    待学
    Pycharm默认输入状态是insert状态,选中文字无法直接输入替换或删除
    使用jsonify返回json数据
    Linux
    Linux
    Linux
    JavaScript
    JavaScript
  • 原文地址:https://www.cnblogs.com/sode/p/2194663.html
Copyright © 2020-2023  润新知