The following works flawlessly (as far as I can tell) in all other browsers:
document.documentElement.innerHTML = "<head></head><body>Testing</body>";
But chokes in IE (I tested IE9), with a console error:
SCRIPT600: Invalid target element for this operation.
...referencing the first character of the line of code above.
Why won't this work in IE, but will work in all other browsers? I read somewhere that innerHTML
has issues replacing 'TBODY' elements, but I tested this line of code after removing all TBODY children and the same error occurred.
I know this sounds like bad-news-code, but it is the only option I have left with the very limited and simplistic CMS website we are being forced to use. I'm only thankful that the CMS allows scripts to be executed.
In essence, I need to be able to completely gut the HTML contents and use my own. Again, this works fine on other browsers.
Other notes:
- The CMS is using the
prototype.js
library (it's already loaded before I run this code) - The Doctype is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- The CMS scripts use
prototype.js
to dynamically add twodiv
s full of content at page load