![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
On Dec 11, 3:36 pm, "rf" <r... (AT) invalid (DOT) com> wrote: "Mahernoz" <maher... (AT) gmail (DOT) com> wrote in message In any case consider "e; -- Richard. I am stuck up here with a bug in IE6. to simplify i have made a demo program. p onclick="alert(this.innerHTML);"><font class="AInput">3434</font></ p it surprisingly removes the double quotes in IE6. I need that when onclick is fired i should also get double quotes. which means... i need <font class="AInput">3434</font> output instead of font class=AInput>3434</font> as output. |
#12
| |||
| |||
|
|
On Dec 11, 8:27 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote: On Dec 11, 2:54 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote: [...] Given: p onclick="alert(this.innerHTML);">get "innerHTML"</p IE 6 shows: get "innerHTML" so your issue is not with the innerHTML property itself. [...] if i replace that string with this string then there are no double quotes... p onclick="alert(this.innerHTML);"><font class="AInput">3434</font></ p it surprisingly removes the double quotes. Quotes around attribute values are not mandatory in HTML, they are only required where the value has certain characters: "In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them." URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 I guess whoever implemented innerHTML in IE decided to remove them where they aren't required. As David said, there is no public standard for innerHTML and what there is at MSDN is scant - it does not say that it returns exactly the original source. So you are left to parse the value yourself and insert quotes as appropriate. You should also convert attribute names to lower case, as some browsers will report them in uppercase. I think the whole idea of using innerHTML as the source of valid XML markup is flawed. -- Rob |
#13
| |||
| |||
|
|
On Dec 11, 3:53 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote: On Dec 11, 8:27 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote: On Dec 11, 2:54 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote: [...] Given: p onclick="alert(this.innerHTML);">get "innerHTML"</p IE 6 shows: get "innerHTML" so your issue is not with the innerHTML property itself. [...] if i replace that string with this string then there are no double quotes... p onclick="alert(this.innerHTML);"><font class="AInput">3434</font></ p it surprisingly removes the double quotes. Quotes around attribute values are not mandatory in HTML, they are only required where the value has certain characters: "In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them." URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2 I guess whoever implemented innerHTML in IE decided to remove them where they aren't required. As David said, there is no public standard for innerHTML and what there is at MSDN is scant - it does not say that it returns exactly the original source. So you are left to parse the value yourself and insert quotes as appropriate. You should also convert attribute names to lower case, as some browsers will report them in uppercase. I think the whole idea of using innerHTML as the source of valid XML markup is flawed. -- Rob Hi, I think the whole idea of using innerHTML as the source of valid XML markup is flawed. - Can you recommend a method which is a "better way" to take the html- contents of a DIV from an html file and put it into a database. (this html will be rendered on a page, so i need to make it well-formed.) |
#14
| |||
| |||
|
|
I am stuck up here with a bug in IE6. |
|
to simplify i have made a demo program. p onclick="alert(this.innerHTML);"><font class="AInput">3434</font></ p it surprisingly removes the double quotes in IE6. |
#15
| |||
| |||
|
|
Mahernoz said the following on 12/11/2007 5:42 AM: snip I am stuck up here with a bug in IE6. No, there is no "bug" in IE6 with regards to what you are seeing. to simplify i have made a demo program. p onclick="alert(this.innerHTML);"><font class="AInput">3434</font></ p it surprisingly removes the double quotes in IE6. It removes quotes that aren't required. Want it to leave the quotes? Add a trailing space. Won't make a hill of beans to HTML but it will cause IE to leave the optional quote marks. p onclick="alert(this.innerHTML);"><font class="AInput ">3434</font></ p Note the space after the class name. |
#16
| |||
| |||
|
|
One could say that the string is build anew from the requested element's inner DOM tree. Example file [IE7]: table onclick='alert(this.innerHTML)' tr><td>Blah</tr></td table |
|
alerts thus: TABLE TBODY TR TD>Blah </TD></TR></TBODY></TABLE And this file [IE7]: div onclick='alert(this.innerHTML)' table tr><td Blah /table /div alerts EXACTLY the same RENDERED code as the first file example did!!!! |
#17
| |||
| |||
|
|
Randy Webb wrote on 11 dec 2007 in comp.lang.javascript: Mahernoz said the following on 12/11/2007 5:42 AM: snip I am stuck up here with a bug in IE6. No, there is no "bug" in IE6 with regards to what you are seeing. to simplify i have made a demo program. p onclick="alert(this.innerHTML);"><font class="AInput">3434</font></ p it surprisingly removes the double quotes in IE6. It removes quotes that aren't required. Want it to leave the quotes? Add a trailing space. Won't make a hill of beans to HTML but it will cause IE to leave the optional quote marks. p onclick="alert(this.innerHTML);"><font class="AInput ">3434</font></ p Note the space after the class name. It seems some of us expect innerHTML to return the HTML script from the html file that rendered the browser page. |
|
This is not the case!! innerHTML just returns the string version of the rendered html in the browser. |
#18
| |||
| |||
|
|
It seems some of us expect innerHTML to return the HTML script from the html file that rendered the browser page. div id="someContainer">old content</div document.getElementById('someContainer').innerHTML ="new content"; alert(document.getElementById('someContainer').inn erHTML); Should the alert give you "old content" or "new content"? |
|
This is not the case!! innerHTML just returns the string version of the rendered html in the browser. It returns the normalized HTML that the browser is using. |
#19
| |||||
| |||||
|
|
Randy Webb wrote on 11 dec 2007 in comp.lang.javascript: It seems some of us expect innerHTML to return the HTML script from the html file that rendered the browser page. div id="someContainer">old content</div document.getElementById('someContainer').innerHTML ="new content"; alert(document.getElementById('someContainer').inn erHTML); Should the alert give you "old content" or "new content"? In IE7 I get "new content", as expected. |
|
Expected, because that is the textNode reconstructed into a Javascript string, and then alerted out. |
|
"Should" however is what the specs say. [If they do] |
|
This is not the case!! innerHTML just returns the string version of the rendered html in the browser. It returns the normalized HTML that the browser is using. I do not think the browser is "using" a normalized HTML sting. |
|
The browser just renders the DOM from the html file text as it is. What the browser reconstructs from the DOM to a string for use in innerHTML, would you call that "normalized"? |
#20
| |||
| |||
|
|
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote: I have some problem here. I am using Asp.net 2.0 but that is not ^^^^^^^^^^^^^^^^^^^^^^ relevant to my Question. I have a <div> tag. div id="dvAArea" runat="server"></div Div elements don't have a runat attribute in HTML 4. |
![]() |
| Thread Tools | |
| Display Modes | |
| |