I am getting error only in IE7 as document.body is null; when I debug with Microsoft script editor I am getting the error in the following line: i.e.
document.body
May also want to use "documentElement":
var elem = document.createElement("div"); elem.style = "width:100px;height:100px;position:relative;background:#FF0000;"; document.documentElement.appendChild(elem);