html5 新标签支持js写法

来源:互联网 发布:淘宝信用卡分期买手机 编辑:程序博客网 时间:2024/06/07 18:35

先上代码  用js创建新的标签元素,使ie支持html5新标签

<script type="text/javascript"><!--   (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>
通过Jscript中@cc_on 语句识别IE浏览器及版本的代码

if(!/*@cc_on!@*/0)    IE11一下执行此代码

If your browser doesn't know conditional compilation (other than IE < 11), the expression will be:

if(!0) // ==> TRUE

otherwise it will be:

if(!!0) // ==> FALSE

/*@cc_on @*//*@    document.write("JavaScript version: " + @_jscript_version + ".");    document.write("<br />");    @if (@_win32)        document.write("Running on the 32-bit version of Windows.");    @elif (@_win16)        document.write("Running on the 16-bit version of Windows.");    @else        document.write("Running on a different operating system.");    @end@*/

原文地址https://stackoverflow.com/questions/24473882/what-does-this-comment-cc-on-0-do-inside-an-if-statement-in-javascript



检测浏览器是不是ie的方法

var isIE = !!document.all && document.uniqueID;

var isIE = navigator.userAgent.indexOf("MSIE") > -1;

//from MooTools 1.1.2if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;else if (document.getBoxObjectFor != null || window.mozInnerScreenX != null) window.gecko = true;




















原创粉丝点击