标签:动态引入js文件
<script type="text/javascript"> function loadJS(path){ var oHead = document.getElementsByTagName('HEAD').item(0); var oScript= document.createElement("script"); oScript.type = "text/javascript"; oScript.src=path; oHead.appendChild( oScript); } /** IE8浏览器需要添加canvas支持 */ function lessIE8(){ if(!+[1,]){// 万恶的IE浏览器! try{ var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0; if(Sys.ie) document.getElementById('browserVersion').innerText= "IE "+Sys.ie; if(Sys.firefox) document.getElementById('browserVersion').innerText= "FireFox "+Sys.firefox; if(Sys.chrome) document.getElementById('browserVersion').innerText= "Chrome "+Sys.chrome; if(Sys.opera) document.getElementById('browserVersion').innerText= "Opera "+Sys.opera; if(Sys.safari) document.getElementById('browserVersion').innerText= "Safari "+Sys.safari; return (parseInt(Sys.ie)< 9); // 更万恶的低版本IE浏览器! }catch(e){ return false;// 默认支持HTML5 } } } //if(lessIE8()) loadJS("admin-ROOT/js/chart/excanvas.compiled.js"); </script>
标签:动态引入js文件
原文地址:http://blog.csdn.net/asiaasia666/article/details/43852947