Hi,
So I’ve searched around on this error and there seem to be a lot of discussions, but I haven’t been able to find an answer for my specific problem. So here’s a basic example of what I’m trying to do, as the real one is long. The whole purpose of this was to avoid going to the database again.
There is a page that loads an article from a Java bean (J2EE that is) with a headline and body property. So I’ve placed a span around the headline with an id and the same with the body, I think it’s a div on the body, doesn’t really matter, problem is the same. I wrote a javascript function to create a form, a text input for the headline, and a textarea for the body, all in a hidden div, and then the function submits the form to a popup and creates a printer friendly version of the page. I didn’t want to have to retrieve the article from the database when I can just send it in the post. This works very well in Firefox, then I tried it in IE and got the very useful error “Unknown runtime error”, thanks. Here’s a small example that produces the same error.
<html>
<head>
<title>Test page</title>
<script type="text/javascript">
<!--
function doSomethingWithInnerHTML() {
var bodyText = document.createElement('textarea');
bodyText.innerHTML = document.getElementById('helloWorld').innerHTML;
document.getElementById('myDiv').appendChild(bodyText);
}
// -->
</script>
</head>
<body>
<span id="helloWorld">
<h3>Hello</h3><h1>World</h1></span>
<div id="myDiv" style="background:#00ff00;color:#ffffff">
<a href="javascript:doSomethingWithInnerHTML()">innerHTML Test</a>
</div>
</body>
</html>
I’ve seen similar threads on this problem and the general solution is to wrap things in a div tag, but I had tried this which seems to work in IE but gives blank text area in Firefox. At this point I decided to cut my losses on this and just do it on the backend side of things which I far more control over. But I’d like to know if there is a good solution for this.