Function callback (RES) {
var node = document.createelement (' div ');
node.innerhtml = res;
Document.body.appendChild (node);
var scriptnodes = node.getelementsbytagname (' script ');
var len = scriptnodes.length;
var stylenodes = node.getelementsbytagname (' style ');
var len1 = scriptnodes.length;
for (var i=0; i<len; i++) {
var scriptnode = document.createelement (' script ');
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);
Ajax loads the HTML file and executes the JS code in it, loading the CSS style