Opera and innerHTML: unconventional behavior?

H

Henri

Hello ppl,

I came accross this unusual problem. It seems that Opera's innerHTML does
not behave like IE's or Firefox's.
Say I have to change the content of a div. I use

document.getElementById('thediv').innerHTML = updated_html;

thediv has a border property so I can see what's going on. In IE and
Firefox, the content
of thediv is effectively replaced by updated_html. But with Opera (latest
version: 9.25)the content of the div is cleared and updated_html is
written underneath (ie OUTSIDE) thediv.

Obviously there's something I'm missing here. Can somebody enlighten me
on this issue?

Thanks
 
P

pr

Henri said:
I came accross this unusual problem. It seems that Opera's innerHTML does
not behave like IE's or Firefox's.
Say I have to change the content of a div. I use

document.getElementById('thediv').innerHTML = updated_html;

thediv has a border property so I can see what's going on. In IE and
Firefox, the content
of thediv is effectively replaced by updated_html. But with Opera (latest
version: 9.25)the content of the div is cleared and updated_html is
written underneath (ie OUTSIDE) thediv.

Obviously there's something I'm missing here. Can somebody enlighten me
on this issue?

You're almost certainly writing invalid HTML, which is causing Opera to
insert a premature end tag for the div. This works for me in Opera 9.25:

document.getElementById('thediv').innerHTML = "<b>fish</b>";

Try it.

A URL to your page might prove enlightening, or at the very least the
value of the updated_html variable.
 
H

Henri

You're almost certainly writing invalid HTML, which is causing Opera to
insert a premature end tag for the div. This works for me in Opera 9.25:

document.getElementById('thediv').innerHTML = "<b>fish</b>";

Try it.

A URL to your page might prove enlightening, or at the very least the
value of the updated_html variable.

Good call!

Thanks
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top