I am working on some stuff meanwhile i get into something which i didn't understand core reason behind it.
my idea(good or bad) is to clone a document and add changes to it and then reassign my cloned object into document
var tu=document.clone(true);
getComputedStyles(document)//returns all current css values
tu.getElementsByTagName("body")[0].style.backgroundColor="yellow";//when i print tu and inspect style is visible on body
tu.getElementsByTagName("body")[0].style.width="100px";
getComputedStyles(tu)//returns all empty values.
document=tu;
But every step return without an error but after assigning tu to document my body bgColor is still white.
one more thing why getComputedStyles() are returning empty values?
Finally i got something which might be usefull
var documentClone=document.clone(true);
documentClone.body.style.background="yellow";
documentClone.body.style.background="red";`\\many number of operations`
//after many changes
document.replaceChild(documentClone.documentElement,document.documentElement);
//now you can find all your changes..
window.document
是不可写的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.