//動態載入外部js檔案
var flag = true;
if( flag ){
loadScript( "js/index.js" );
};
function loadScript( url ){
var script = document.createElement( "script" ) ;
script.type = "type/javascipt";
script.src = url;
document.getElementsByTagName( "head" )[0].appendChild( script );
};
// 動態載入js
if( flag ){
var script = document.createElement( "script" );
script.type = "text/javascript";
script.text = " ";
document.getElementsByTagName( "head" )[0].appendChild( script );
};
// 動態載入外部css樣式
if( flag ){
loadCss( "css/base.css" );
};
function loadCss( url ){
var link = document.createElement( "link" );
link.type = "text/css" ;
link.rel = "stylesheet";
link.href = url;
document.getElementsByTagName( "head" )[0].appendChild( link );
};
/ / 動態載入css樣式
if( flag ){
var style = document.createElement( "style" );
style.type = "text/css";
document.getElementsByTagName( "headhead " )[0].appendChild( style );
var sheet = document.styleSheets[0];
insertRules( sheet,"#gaga1","background:#f00",0 );
} ;
function insertRules( sheet,selectorTxt,cssTxt,position ){
if( sheet.insertRule ){ // 判斷非IE瀏覽器
sheet.insertRule( selectorTxt "{" cssTx"}" );
}else if( sheet.addRule ){ //判斷是否為IE瀏覽器
sheet.addRule( selectorTxt ,cssTxt ,position )
}
}