innerhtml.... produces Microsoft Internet Explorer error

J

Jason

I have a web page that contains textareas. These are dynamically
added via asp when the page loads based on database records. The user
also has the ability to add more text areas via innerhtml. If the
user clicks the add text area button too fast or too many times.. they
will get the following error:

Internet Explorer Has Encountered a Problem and Needs to Close.

After reading msdns page about this error I doubt that there is a fix
to this. However, any suggestions on how I could work around this
error with a different approach than innerhtml? Any help would be
greatly appreciated. Please see the example below.

<html>
<script language="javascript">
function addvalue(){

myid.innerHTML += '<div id="mydiv2"><table border=0 cellpadding=0
cellspacing=0><tr><td width=80 align="center">&nbsp;<td><td><textarea
name="mytext"></textarea></td></tr></table></div>';
}


</script>



<body>
clicking too fast can cause ie
error<table><tr><td><table><tr><td><table><tr><td>
<input type="button" OnClick="addvalue();" value="add text area">
<div id="myid"><%
'asp code that dynamically adds textareas

%>
</td></tr></td></tr></td></tr></table>
</div>
</body>
</html>
 
M

Mick White

Jason said:
I have a web page that contains textareas. These are dynamically
added via asp when the page loads based on database records. The user
also has the ability to add more text areas via innerhtml. If the
user clicks the add text area button too fast or too many times.. they
will get the following error:

Internet Explorer Has Encountered a Problem and Needs to Close.

After reading msdns page about this error I doubt that there is a fix
to this. However, any suggestions on how I could work around this
error with a different approach than innerhtml? Any help would be
greatly appreciated. Please see the example below.

<html>
<script language="javascript">
function addvalue(){

myid.innerHTML += '<div id="mydiv2"><table border=0 cellpadding=0
cellspacing=0><tr><td width=80 align="center">&nbsp;<td><td><textarea
name="mytext"></textarea></td></tr></table></div>';
}


</script>

2 problems:
myid.innerHTML s/b:
document.getElementById("myid").innerHTML

You need form tags.
Mick
 
B

Bill

Thank you for the reply!! However, both of the issues you mentioned are
taken care of on my live page. I was using that html/javascript as an
example. What I am looking for is an alternative to using innerhtml as
to avoid the internet explorer error. Talk to you soon.
 
K

kaeli

Thank you for the reply!! However, both of the issues you mentioned are
taken care of on my live page. I was using that html/javascript as an
example. What I am looking for is an alternative to using innerhtml as
to avoid the internet explorer error. Talk to you soon.

Use real DOM methods as applicable. See createElement, appendChild,
createTextNode, etc.

http://msdn.microsoft.com/library/default.asp?
url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp

function addvalue(someNode)
{
myNewElement = document.createElement("div");
myNewElement.setAttribute("id","mydiv2");
someNode.appendChild(myNewElement);
}

e = document.getElementById("someDiv");
addValue(e);

--
--
~kaeli~
The Bermuda Triangle got tired of warm weather. It moved to
Finland. Now Santa Claus is missing.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top