473,652 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8060

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.ne t.ausaid:
>
Dan Michael Heggå wrote:
>Hi,
I've working on inplace-editing. My problem is the following: This
works in all browsers:

myDiv.innerHTM L = "<p>...</p>";

but this doesn't work in IE:

myDiv.innerHTM L = "<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*****@litote s.demon.co.uksa id:
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
1726
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>"); Thanks
3
1974
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 don't know why. My "development" machine is just my home machine. I'm connected to the Internet via an AOL dialup connection. I am running on XP Pro and my IIS server is (apparently) configured
2
9560
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 input boxes. I then take the innerHTML from my <div> and add the new table to the existing one/s. What happens in FireFox is that all values in other tables input boxes
3
11420
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 found that innerHTML is read only for tables in IE which is a problem, please see my code below. I need urgent help if anyone has an idea or a helpfull link, any help will be greatly appreciated! PS: dont mind the PHP CODE BELOW --- <?php
4
5124
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 child window. The function that is called contains an XMLHttpRequest. My problem is that everything happens as it should, the innerHTML is changed by the results of the XMLHttpRequest and the child window closes. The problem is this, in Firefox,...
7
38002
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 using innerHTML. Now, I've researched this problem on the web, and found many references to it, but none of them quite addressed my specific situation, and since my experience with JavaScript is limited, I was not able to adapt the solutions I...
2
3148
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 i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand whats the prob.this is the code i m using: <? include("config.inc.php"); //error_reporting(0); ...
7
10257
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 lack some JavaScript solid knowdlege) The problem is that when I try to send a form's content with Ajax (I'm using the prototype library), for some reason the latin characters (accents and stuff, like áéíóú) turn a mess when I try to store them in...
58
8063
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 the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
1
4396
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 attached a Log from HTTPAnalyzer. Anyhow, here's the code I'm running, Class File: HTMLElement.Upload = function(Params) { var FORM = new HTMLElement(HTMLElement.FORM,{
0
8370
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8704
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.