469,272 Members | 1,448 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Problem with innerHtml and the form-tag in IE

Hi,
I've working on inplace-editing. My problem is the following: This
works in all browsers:

myDiv.innerHTML = "<p>...</p>";

but this doesn't work in IE:

myDiv.innerHTML = "<form>...</form>";

It seems like IE doesn't accept the <form>-tag in innerHTML. However,
I've not managed to find any documentation on this. I've made a very
small example available at:

http://www.student.uib.no/~dhe080/of...innerhtml.html

The "paragraph"-button should work in all browsers, while the
"form"-button doesn't seem to work in IE.

Thanks!
Dan Michael

Nov 12 '06 #1
4 7805

Dan Michael Heggå wrote:
Hi,
I've working on inplace-editing. My problem is the following: This
works in all browsers:

myDiv.innerHTML = "<p>...</p>";

but this doesn't work in IE:

myDiv.innerHTML = "<form>...</form>";

It seems like IE doesn't accept the <form>-tag in innerHTML. However,
I've not managed to find any documentation on this. I've made a very
small example available at:

http://www.student.uib.no/~dhe080/of...innerhtml.html

The "paragraph"-button should work in all browsers, while the
"form"-button doesn't seem to work in IE.
It "works" in IE 6 for me, though I would not encourage creating forms
using innerHTML, DOM methods should be safer.

Do not use XML-style tag closures ( />) for HTML. IE does not have any
understanding of XML, use HTML 4.01 Strict.

--
Rob

Nov 13 '06 #2
On 2006-11-13 01:44:26 +0100, "RobG" <rg***@iinet.net.ausaid:
>
Dan Michael Heggå wrote:
>Hi,
I've working on inplace-editing. My problem is the following: This
works in all browsers:

myDiv.innerHTML = "<p>...</p>";

but this doesn't work in IE:

myDiv.innerHTML = "<form>...</form>";

It seems like IE doesn't accept the <form>-tag in innerHTML. However,
I've not managed to find any documentation on this. I've made a very
small example available at:

http://www.student.uib.no/~dhe080/of...innerhtml.html

The "paragraph"-button should work in all browsers, while the
"form"-button doesn't seem to work in IE.

It "works" in IE 6 for me, though I would not encourage creating forms
using innerHTML, DOM methods should be safer.
Thank's for your reply. It's strange that it works with your IE, but
not with mine.. Maybe it's because I use Win2k? :) Well, I ended up
using a button with onclick instead of a submit button - and then skip
the form.
Do not use XML-style tag closures ( />) for HTML. IE does not have any
understanding of XML, use HTML 4.01 Strict.
Really? It's a little late to change the doctype of the site, since
it's three years old and has grown quite big. Is this a problem only
when using innerHtml or in common? I haven't noticed any problems with
the /so far.

-DM

Nov 13 '06 #3
Dan Michael Heggå wrote:
RobG said:
<snip>
>Do not use XML-style tag closures ( />) for HTML. IE does not have
any understanding of XML, use HTML 4.01 Strict.

Really? It's a little late to change the doctype of the site, since
it's three years old and has grown quite big. Is this a problem only
when using innerHtml or in common? I haven't noticed any problems with
the /so far.
Using - innerHTML - highlights the issue. You have not had a problem
because you server your XHTML-like mark-up with a content-type header
of text/html, which effetely asserts that the document is an HTML
document. So the browsers interpret your document as HTML, tag soup
HTML with lots of errors (the aspects of the mark-up that would make it
XML in other contexts), and error-correct your mark-up back to HTML
that they are capable of handling.

This means that when you come to script the document the browser is
providing an HTML DOM to be scripted rather than an XHTML DOM. And
because the browser is providing an HTML DOM you can use features such
as - innerHTML - because they work there but often don't work in XHTML
DOMs.

However, if a DOM is scripted as an HTML DOM, and because most
non-trivial HTML DOM scripts will not work at all in an XHTML DOM, it
becomes important that the document in question is only ever
interpreted as HTML. And if the scripting of a document is absolutely
dependent upon its mark-up being interpreted only as HTML it is not
rational for that mark-up to resemble the XHTML that it must never be
interpreted as by a web browser. It is generally difficult to persuade
programmers that doing something that is irrational is a good idea.

Richard.

Nov 13 '06 #4
On 2006-11-13 15:05:21 +0100, "Richard Cornford"
<Ri*****@litotes.demon.co.uksaid:
Dan Michael Heggå wrote:
>RobG said:
<snip>
>>Do not use XML-style tag closures ( />) for HTML. IE does not have
any understanding of XML, use HTML 4.01 Strict.

Really? It's a little late to change the doctype of the site, since
it's three years old and has grown quite big. Is this a problem only
when using innerHtml or in common? I haven't noticed any problems with
the /so far.

Using - innerHTML - highlights the issue. You have not had a problem
because you server your XHTML-like mark-up with a content-type header
of text/html, which effetely asserts that the document is an HTML
document. So the browsers interpret your document as HTML, tag soup
HTML with lots of errors (the aspects of the mark-up that would make it
XML in other contexts), and error-correct your mark-up back to HTML
that they are capable of handling.

This means that when you come to script the document the browser is
providing an HTML DOM to be scripted rather than an XHTML DOM. And
because the browser is providing an HTML DOM you can use features such
as - innerHTML - because they work there but often don't work in XHTML
DOMs.

However, if a DOM is scripted as an HTML DOM, and because most
non-trivial HTML DOM scripts will not work at all in an XHTML DOM, it
becomes important that the document in question is only ever
interpreted as HTML. And if the scripting of a document is absolutely
dependent upon its mark-up being interpreted only as HTML it is not
rational for that mark-up to resemble the XHTML that it must never be
interpreted as by a web browser. It is generally difficult to persuade
programmers that doing something that is irrational is a good idea.
Thanks for clarifying this, Richard.

--
Dan Michael

Nov 16 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Geoff Cox | last post: by
3 posts views Thread by Steve Thurston | last post: by
2 posts views Thread by sveinn | last post: by
4 posts views Thread by tcole6 | last post: by
Canabeez
1 post views Thread by Canabeez | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.