in Hacking

Don’t use innerHTML, but use Prototype’s Element.update method!

Note to self: When using prototype don’t use the innerHTML property.

Internet Explorer has got a (in my opinion) broken implementation for certain elements.
It is not possible to change the innerHTML content of the TR and SELECT elements.

Fortunally Prototype has fixed these problems in the Element.update method!


$("tr_id").update( "

Test

" );

Share
  1. brilliant. i’ve only recently begun using the JS prototype framework and was looking for a function to replace innerHTML. i must have overlooked this in the API documentation.

    thank you so much.

    xx

  2. Perfect. Also fixes the problem of the disappearing SCRIPT tags in IE7 when dynamically adding javascritp to the DOM.

    elm.innerHTML(‘…’)
    Some times (not always) the script node disappears

    elm.update(‘…’)
    Works. The script still needs to be run using eval later tthough

  3. What if I just want to read the inner html and use it elsewhere? Such as to parse my ajax response 17 to retrieve the 17 to use elsewhere.

  4. trying that again:
    What if I just want to read the inner html and use it elsewhere? Such as to parse my ajax response
    <div id=”tool_body”>17</div> to retrieve the 17 to use elsewhere.

  5. Reading is no problem, the problem is writing to innerHTML.

Comments are closed.