Code:
var nods = frames[0].document.body.cloneNode(true).childNodes, op = document.getElementById('loader'); while(op.hasChildNodes()) op.removeChild(op.firstChild); for(var i = 0, n = nods.length; i < n; ++i) op.appendChild(nods[i]);
Probably best abstracted into some functions:
Code:
var Dom = (function() {
function clearChildren(nod) {
while(nod.hasChildNodes())
nod.removeChild(nod.firstChild);
return nod;
}
function cloneChildren(inp, out) {
var nods = inp.cloneNode(true).childNodes;
Dom.clearChildren(out);
for(var i = 0, n = nods.length; i < n; ++i)
out.appendChild(nods[i]);
return inp;
}
function getElementById(id) {
var f;
return document.getElementById(id)
|| (f = document.getElementsByName(id) && f[0]);
}
getElementById.clearChildren = clearChildren;
getElementById.cloneChildren = cloneChildren;
return getElementById;
})();
onload = function() {
Dom.cloneChildren(frames[0].document.body, Dom("loader"));
};
Bookmarks