HighDots Forums  

Problem dealing with double quotes in InnerHTML

Javascript JavaScript language (comp.lang.javascript)


Discuss Problem dealing with double quotes in InnerHTML in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mahernoz
 
Posts: n/a

Default Problem dealing with double quotes in InnerHTML - 12-11-2007 , 01:10 AM






Hi Friends,

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>

and an HiddenField

<input type="hidden" runat="server" id="hidAArea" />

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
}


the problem here is i want to make the html of dvAArea Xml compatible.
but i am finding that the innerHTML property removes the double quotes
in IE6.



And as this removal occurs i cannot load it as a validXml (which is
used for other purpose).



Regards,
Mahernoz



Reply With Quote
  #2  
Old   
RobG
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 01:25 AM






On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
Quote:
Hi Friends,

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.

Quote:
and an HiddenField

input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
Don't post sever code, post what your client gets. How you program
your server to do that is your reponsibility. Questions relating to
server-side programming should be asked in a community forum that
supports your chosen server technology.

As far as I can tell, your div element doesn't have any child nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?


Quote:
}

the problem here is i want to make the html of dvAArea Xml compatible.
but i am finding that the innerHTML property removes the double quotes
in IE6.
It is something of a paradox to want to use innerHTML to insert "XML
compatible". But maybe I'm just easily amused. :-)


Quote:
And as this removal occurs i cannot load it as a validXml (which is
used for other purpose).
Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...


--
Rob


Reply With Quote
  #3  
Old   
Mahernoz
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 01:31 AM



On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
Quote:
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:

Hi Friends,

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.



and an HiddenField

input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);

Don't post sever code, post what your client gets. How you program
your server to do that is your reponsibility. Questions relating to
server-side programming should be asked in a community forum that
supports your chosen server technology.

As far as I can tell, your div element doesn't have any child nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}

the problem here is i want to make the html of dvAArea Xml compatible.
but i am finding that the innerHTML property removes the double quotes
in IE6.

It is something of a paradox to want to use innerHTML to insert "XML
compatible". But maybe I'm just easily amused. :-)

And as this removal occurs i cannot load it as a validXml (which is
used for other purpose).

Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...

--
Rob
the code generated in div is html but it is also a wellformed xml.
any answers?


Reply With Quote
  #4  
Old   
Mahernoz
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 01:35 AM



On Dec 11, 12:31 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
Quote:
On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:



On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:

Hi Friends,

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.

and an HiddenField

input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);

Don't post sever code, post what your client gets. How you program
your server to do that is your reponsibility. Questions relating to
server-side programming should be asked in a community forum that
supports your chosen server technology.

As far as I can tell, your div element doesn't have any child nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}

the problem here is i want to make the html of dvAArea Xml compatible.
but i am finding that the innerHTML property removes the double quotes
in IE6.

It is something of a paradox to want to use innerHTML to insert "XML
compatible". But maybe I'm just easily amused. :-)

And as this removal occurs i cannot load it as a validXml (which is
used for other purpose).

Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...

--
Rob

the code generated in div is html but it is also a wellformed xml.
any answers?
putted simply i am finding trouble using innerHTML property with
Internet Explorer as it removes the "double quotes" from my rendered
html.
i am just looking for a way so that the double quotes are not removed
when innerHTML is called in Internet Explorer (mozilla works fine).

Regards,
Mahernoz


Reply With Quote
  #5  
Old   
RobG
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 03:54 AM



On Dec 11, 5:35 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
Quote:
On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
[...]
I have a <div> tag.
div id="dvAArea" runat="server"></div
and an HiddenField
input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
[...]
As far as I can tell, your div element doesn't have any child nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}
[...]
Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...
[...]
putted simply i am finding trouble using innerHTML property with
Internet Explorer as it removes the "double quotes" from my rendered
html.
i am just looking for a way so that the double quotes are not removed
when innerHTML is called in Internet Explorer (mozilla works fine).
Given:

<p onclick="alert(this.innerHTML);">get "innerHTML"</p>

IE 6 shows:

get "innerHTML"

so your issue is not with the innerHTML property itself.


--
Rob


Reply With Quote
  #6  
Old   
Mahernoz
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 04:27 AM



On Dec 11, 2:54 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
Quote:
On Dec 11, 5:35 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:



On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
[...]
I have a <div> tag.
div id="dvAArea" runat="server"></div
and an HiddenField
input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
[...]
As far as I can tell, your div element doesn't have any child nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}
[...]
Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...
[...]
putted simply i am finding trouble using innerHTML property with
Internet Explorer as it removes the "double quotes" from my rendered
html.
i am just looking for a way so that the double quotes are not removed
when innerHTML is called in Internet Explorer (mozilla works fine).

Given:

p onclick="alert(this.innerHTML);">get "innerHTML"</p

IE 6 shows:

get "innerHTML"

so your issue is not with the innerHTML property itself.

--
Rob

Hi,

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.

Regards,
Mahernoz


Reply With Quote
  #7  
Old   
rf
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 04:36 AM




"Mahernoz" <mahernoz (AT) gmail (DOT) com> wrote

Quote:
On Dec 11, 2:54 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:35 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:



On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
[...]
I have a <div> tag.
div id="dvAArea" runat="server"></div
and an HiddenField
input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID
%>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
[...]
As far as I can tell, your div element doesn't have any child
nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}
[...]
Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...
[...]
putted simply i am finding trouble using innerHTML property with
Internet Explorer as it removes the "double quotes" from my rendered
html.
i am just looking for a way so that the double quotes are not removed
when innerHTML is called in Internet Explorer (mozilla works fine).

Given:

p onclick="alert(this.innerHTML);">get "innerHTML"</p

IE 6 shows:

get "innerHTML"

so your issue is not with the innerHTML property itself.

--
Rob


Hi,

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.
I have read this thread very very carefully and find that

a) it has little if anything to do with javascript.

b) I don't know what it actually has to do with. You keep mentioning double
quotes and their removal but you fail to mention where they are exactly
removed from.

In any case consider &quote;

--
Richard.




Reply With Quote
  #8  
Old   
Mahernoz
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 04:42 AM



On Dec 11, 3:36 pm, "rf" <r... (AT) invalid (DOT) com> wrote:
Quote:
"Mahernoz" <maher... (AT) gmail (DOT) com> wrote in message

news:d401bce5-a592-42d3-ae77-40505450d005 (AT) i29g2000prf (DOT) googlegroups.com...



On Dec 11, 2:54 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:35 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:

On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
[...]
I have a <div> tag.
div id="dvAArea" runat="server"></div
and an HiddenField
input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID
%>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
[...]
As far as I can tell, your div element doesn't have any child
nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}
[...]
Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...
[...]
putted simply i am finding trouble using innerHTML property with
Internet Explorer as it removes the "double quotes" from my rendered
html.
i am just looking for a way so that the double quotes are not removed
when innerHTML is called in Internet Explorer (mozilla works fine).

Given:

p onclick="alert(this.innerHTML);">get "innerHTML"</p

IE 6 shows:

get "innerHTML"

so your issue is not with the innerHTML property itself.

--
Rob

Hi,

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.

I have read this thread very very carefully and find that

a) it has little if anything to do with javascript.

b) I don't know what it actually has to do with. You keep mentioning double
quotes and their removal but you fail to mention where they are exactly
removed from.

In any case consider &quote;

--
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.

Regards,
Mahernoz


Reply With Quote
  #9  
Old   
David Mark
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 04:43 AM



On Dec 11, 5:27 am, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
Quote:
On Dec 11, 2:54 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:



On Dec 11, 5:35 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:

On Dec 11, 12:25 pm, RobG <rg... (AT) iinet (DOT) net.au> wrote:
On Dec 11, 5:10 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
[...]
I have a <div> tag.
div id="dvAArea" runat="server"></div
and an HiddenField
input type="hidden" runat="server" id="hidAArea" /

on click of a button i have a function

function CopyHTML()
{
document.getElementById('<%= hidAArea.ClientID %>').value
= MakeXMLParseable(document.getElementById('<%= dvAArea.ClientID
%>').innerHTML);
[...]
As far as I can tell, your div element doesn't have any child nodes,
so its innerHTML property will be an empty string. Where are the
problematic quotes?

}
[...]
Maybe if we could see the attempted XML, what you get and what you
expect, then something more could be said...
[...]
putted simply i am finding trouble using innerHTML property with
Internet Explorer as it removes the "double quotes" from my rendered
html.
i am just looking for a way so that the double quotes are not removed
when innerHTML is called in Internet Explorer (mozilla works fine).

Given:

p onclick="alert(this.innerHTML);">get "innerHTML"</p

IE 6 shows:

get "innerHTML"

so your issue is not with the innerHTML property itself.

--
Rob

Hi,

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.

It isn't that surprising as there is no standard defined for
innerHTML. IE chose to implement it slightly differently than
FireFox. If you need to create an XML document with innerHTML, you
will have to normalize it yourself. You would be better off writing a
wrapper for innerHTML as there are more issues to deal with than
unquoted attribute values.


Reply With Quote
  #10  
Old   
RobG
 
Posts: n/a

Default Re: Problem dealing with double quotes in InnerHTML - 12-11-2007 , 04:53 AM



On Dec 11, 8:27 pm, Mahernoz <maher... (AT) gmail (DOT) com> wrote:
Quote:
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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.