SyntaxFix
Write A Post
Hire A Developer
Questions
It is working. Just modify to null check:
if(document.body != null){ document.body.appendChild(element); }
Pointy's suggestion is good; it may work, but I didn't try.