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.
You could try
document.getElementsByTagName('body')[0].appendChild(i);
Now that won't do you any good if the code is running in the , and running before the has even been seen by the browser. If you don't want to mess with "onload" handlers, try moving your block to the very end of the document instead of the .