473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 8047

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Geoff Cox | last post by:
Hello, How do I get the str_questions values into a form?! The following does not work. I have also tried document.write("<input type='hidden' name='slidervalues' value=str_questions>"); ...
3
by: Steve Thurston | last post by:
Hi, I'm attempting to send emails for the first time using ASP.NET, so I'm hoping there's just a beginner's error going on here for me. But my emails aren't reaching their destination, and I...
2
by: sveinn | last post by:
Hi all, I've read through this group searching for an answear about this problem. Few have come close but not quite what I need. My problem is this: I'm using Ajax to fetch a new table with...
3
by: ilia | last post by:
Hi All, I am a newbie in terms of Javascript, I found some code on the net to swap rows in a table using innerHTML, this works fine in Firefox but IE is complaining, after some googling around I...
4
by: tcole6 | last post by:
My problem appears to be Firefox specific. I have a hyperlink that loads a new window. This window contains hyperlinks that call javascript functions in the parent window and then closes the...
7
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
7
xNephilimx
by: xNephilimx | last post by:
lHi guys! I'm having a little problem that's getting on my nerves, I couldn't find a solution, I also tryed googling it and I found nothing... (my field of expertise is in AS 2 and 3, but I still...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
1
Canabeez
by: Canabeez | last post by:
Hi all, anyone has an idea why IE is not uploading file and FF does? I'm creating a FORM + IFRAME using DOM and trying to upload a file, now Firefox and Chrome do thins perfectly. I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.