load "http://www.ilovejs.net/lab/css.php" first,but it will take two seconds to response. chage the background at div.
and then load "http://www.ilovejs.net/lab/load.css". chage the font-size and font-family
var head = document.getElementsByTagName("head")[0];
var style = document.createElement('style');
//加载css.php文件,需要2秒之后才会返回响应内容
style.textContent = '@import "http://www.ilovejs.net/lab/css/css.php"';
style.rel="stylesheet";
var fi = setInterval(function() {
try {
style.sheet.cssRules; // MAGIC: only populated when file is loaded
//如果css.php加载完毕,那么再加载一个css文件。
var s = document.createElement("style");
s.textContent = '@import "http://www.ilovejs.net/lab/css/load.css"';
s.rel = "stylesheet";
var t = setInterval(function(){
try{
s.sheet.cssRules;
alert("CSS loaded");
}catch(e){}
clearInterval(t);
},10);
head.appendChild(s);
clearInterval(fi);
} catch (e){}
}, 10);
head.appendChild(style);