innerhtml.... produces Microsoft Internet Explorer error

Discussion in 'Javascript' started by Jason, Apr 18, 2004.

  1. Jason

    Jason Guest

    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>
     
    Jason, Apr 18, 2004
    #1
    1. Advertising

  2. Jason

    Mick White Guest

    Jason wrote:
    > 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
    >
    > <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>
     
    Mick White, Apr 18, 2004
    #2
    1. Advertising

  3. Jason

    Bill Guest

    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.


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Bill, Apr 19, 2004
    #3
  4. Jason

    kaeli Guest

    In article <40841568$0$203$>,
    enlightened us with...
    > 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
     
    kaeli, Apr 19, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ed Hauptman
    Replies:
    7
    Views:
    1,093
    Ed Hauptman
    Aug 7, 2009
  2. Replies:
    1
    Views:
    230
    º£Ò»
    Apr 9, 2004
  3. Replies:
    1
    Views:
    172
  4. Replies:
    0
    Views:
    147
  5. Phper
    Replies:
    10
    Views:
    406
    John G Harris
    Sep 14, 2009
Loading...

Share This Page