var minisite = {}; /** * 判断浏览器 */ minisite.browser = { ie: !!window.activexobject || "activexobject" in window, moz: /gecko/.test( window.navigator.useragent.tolowercase() ), opera: /opera/.test( window.navigator.useragent.tolowercase() ), safari: /safari/.test( window.navigator.useragent.tolowercase() ) }; /** * jsloader对象用来加载外部的js文件 */ minisite.jsloader = { /** * 加载外部的js文件 * @param surl 要加载的js的url地址 * @param fcallback js加载完成之后的处理函数 * @param type */ load: function ( surl, type, fcallback ) { var _script = {}; switch( type ){ case 'js': _script = document.createelement( 'script' ); _script.setattribute( 'type', 'text/javascript' ); _script.setattribute( 'async','' ); _script.setattribute( 'charset','utf-8' ); _script.setattribute( 'src', surl ); break; case 'css': _script = document.createelement( 'link' ); _script.setattribute( 'rel', 'stylesheet' ); _script.setattribute( 'type', 'text/css' ); _script.setattribute( 'href', surl ); break; } document.getelementsbytagname( 'head' )[ 0 ].appendchild( _script ); if ( minisite.browser.ie ) { _script.onreadystatechange = function () { if ( this.readystate === 'loaded' || this.readystate === 'complete' ) { //fcallback(); if ( fcallback !== undefined ) { fcallback(); } } }; } else if ( minisite.browser.moz ) { _script.onload = function () { //fcallback(); if ( fcallback !== undefined ) { fcallback(); } }; } else { //fcallback(); if ( fcallback !== undefined ) { fcallback(); } } } };