function callback(res){html
var node = document.createElement('div');node
node.innerHTML = res;app
document.body.appendChild(node);htm
var scriptNodes = node.getElementsByTagName('script');ip
var len = scriptNodes.length;rem
var styleNodes = node.getElementsByTagName('style');get
var len1 = scriptNodes.length;io
for(var i=0; i<len; i++){function
var scriptNode = document.createElement('script');call
if(scriptNodes[0].getAttribute('src')!='' && scriptNodes[0].getAttribute('src')!=null){
scriptNode.setAttribute('src',scriptNodes[0].getAttribute('src'));
}else{
scriptNode.innerHTML = scriptNodes[0].innerHTML;
}
document.body.appendChild(scriptNode);
node.removeChild(scriptNodes[0]);
}
for(var i=0; i<len1; i++){
var styleNode = document.createElement('style');
if(styleNodes[0].getAttribute('src')!='' && styleNodes[0].getAttribute('src')!=null){
styleNode.setAttribute('src',styleNodes[0].getAttribute('src'));
}else{
styleNode.innerHTML = styleNodes[0].innerHTML;
}
document.head.appendChild(styleNode);
node.removeChild(styleNodes[0]);
}
}
var xhr = null;
if(window.XMLHttpRequest){
xhr = new XMLHttpRequest();
}else if(window.ActiveXObject){
xhr = new ActiveXObject("Microsoft.XMLHTTP")
}
xhr.onreadystatechange = function(){
if(xhr.readyState == 4){
if(xhr.status == 200){
callback(xhr.responseText);
}
}
}
xhr.open('get', 'main.html');
xhr.send(null);