# Insertion problems with Opera

**URL:** <https://www.ruby-forum.com/t/insertion-problems-with-opera/101222>\
**Category:** Ruby\
**Created:** [August 3, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/insertion-problems-with-opera/101222 "2006-08-03T17:20:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![schdewwn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@schdewwn](https://www.ruby-forum.com/u/schdewwn)\
**Post date:** [August 3, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/insertion-problems-with-opera/101222/1 "2006-08-03T17:20:25Z")

</div>

Hi,

as I couldn’t figure out how to post to the Ruby Spinoffs forum  
directly, I am starting a new post here and hope some kind admin can  
move it over to the appropriate forum.

I am trying to insert a new row to a table using prototype’s “new  
Insertion.Bottom” which works fine in all popular browsers except for  
Opera. Digging into the code of prototype 1.5.0\_rc0 I discovered that  
insertAdjacentHTML() is used for Opera:

---- lines 1147-1154 —\>  
if (this.adjacency && this.element.insertAdjacentHTML) {  
try {  
this.element.insertAdjacentHTML(this.adjacency, this.content);  
} catch (e) {  
var tagName = this.element.tagName.toLowerCase();  
if (tagName == ‘tbody’ || tagName == ‘tr’) {  
this.insertContent(this.contentFromAnonymousTable());  
} else {  
\<------------------------

If I insert a simple “throw(‘bla’)” in the first try-block, so that the  
catch-part is run, it works in opera.

I boiled down the lengthy code and put up a test case [1] which uses  
insertAdjacentHTML() to add a new table row and you can see (when the  
updated innerHTML of the table is displayed) how opera seems to  
completely ignore the TR and TD tags yet handling B and I correctly.

---- interesting parts from the test case----\>  
tbl = document.getElementById(“mytable”);  
tbl.insertAdjacentHTML(“beforeEnd”,  
“ **newCellone** _newCelltwo_”);  
\<------------------------

I know I could use DOM functions like insertRow() to circumvent that  
problem but I want to make use of prototype’s functions as much as  
possible. I would appreciate any kind of help as to how to maybe change  
the prototype code without breaking other browsers or another way of  
working around this apparent bug.

[1] TEST CASE - [http://buzzinhornetz.ath.cx/tmp/adjacent.html](http://buzzinhornetz.ath.cx/tmp/adjacent.html)

Thanks in advance,  
schdewwn
