zoukankan      html  css  js  c++  java
  • IE兼容html5标签

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

      方式一:引用google的html5.js文件,代码内容可以自己下载下来看。

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

      将以上代码放到head标签区间

      方式二:自己coding JS搞定。

    <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(', ');
         var i= e.length;
         while (i--){
             document.createElement(e[i])
         } 
    })() 
    </script>

      不管你用上面哪中方式,请记得在CSS中进行如下定义,目的是让这些标签成为块状元素,just like div。

    /*html5*/
    article,aside,dialog,footer,header,section,footer,nav,figure,menu{display:block}

  • 相关阅读:
    四则运算结对作业
    读《构建之法》第四、十七章有感
    四则运算练习的命令行软件
    Spring01
    oop01
    运行shell脚本的三种方式
    正则表达式的基础组成部分
    C语言文件函数
    shell文件描述符及重定向
    shell基础
  • 原文地址:https://www.cnblogs.com/yesw/p/4371067.html
Copyright © 2011-2022 走看看