List Info

Thread: Firefox mangling href in innerHTML




Firefox mangling href in innerHTML
country flaguser name
United States
2007-04-23 13:06:34
I'm using 1.5.1_rc2 with Mozilla/5.0 (Windows; U; Windows NT
5.1; en-
US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3.

I suspect strongly that this is a quirk with innerHTML in
Firefox, but
I'm stumped and was hoping someone had a workaround.

Given this code --

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<html>
<head>
<title>inner.html</title>
<script type="text/javascript"
src="js/prototype.js"></script>

<script type="text/javascript">
			Event.observe(window, 'load',
			  function() {
			  	alert($('xyz').innerHTML);
			  }
			);
</script>
</head>
<body>
<div id='xyz'><a id='#'
href='#'>ss#ss</a><span
id='#'></span></div>
</body>
</html>

I would expect the alert() to spit out *EXACTLY* what is
inside the
<div>.  In fact that is what I get with IE7.  However,
with Firefox I
get --

<a id="#"
href="#%7Bid%7D">ss#ss</a><span
id="#{id"'></span>.

Notice two things --

(1) The attributes are now double-quoted instead of
single-quoted.  I
don't think this is a big deal, but it's curious in any
case.

(2) The original href='#' now has the  encoded. 
That
causes a problem when I try to use this string in a
Prototype
Template.  I've been fooling around with this a bit and the
only
attribute on any HTML element that I can find that does this
is the
href inside an <A />.

Anyone know of a way around this?

Thanks in advance!
-Steve.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox mangling href in innerHTML
country flaguser name
United States
2007-04-23 13:09:20
you cannot use single quotes around attributes in HTML.

Try it again with double quotes and see if you still have
the weird
href escaping issue.



On Apr 23, 2:06 pm, "Steve T." <kookn...gmail.com> wrote:
> I'm using 1.5.1_rc2 with Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-
> US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3.
>
> I suspect strongly that this is a quirk with innerHTML
in Firefox, but
> I'm stumped and was hoping someone had a workaround.
>
> Given this code --
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
> <html>
> <head>
> <title>inner.html</title>
> <script type="text/javascript"
src="js/prototype.js"></script>
>
> <script type="text/javascript">
>                         Event.observe(window, 'load',
>                           function() {
>                                
alert($('xyz').innerHTML);
>                           }
>                         );
> </script>
> </head>
> <body>
> <div id='xyz'><a id='#'
href='#'>ss#ss</a><span
> id='#'></span></div>
> </body>
> </html>
>
> I would expect the alert() to spit out *EXACTLY* what
is inside the
> <div>.  In fact that is what I get with IE7. 
However, with Firefox I
> get --
>
> <a id="#"
href="#%7Bid%7D">ss#ss</a><span
id="#{id"'></span>.
>
> Notice two things --
>
> (1) The attributes are now double-quoted instead of
single-quoted.  I
> don't think this is a big deal, but it's curious in any
case.
>
> (2) The original href='#' now has the 
encoded.  That
> causes a problem when I try to use this string in a
Prototype
> Template.  I've been fooling around with this a bit and
the only
> attribute on any HTML element that I can find that does
this is the
> href inside an <A />.
>
> Anyone know of a way around this?
>
> Thanks in advance!
> -Steve.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox mangling href in innerHTML
country flaguser name
United States
2007-04-23 13:15:57
Right, I know that.  Not sure what I was thinking.  But...

The problem still exists.  I replaced all the singles with
doubles and
the exact same problem still happens.

On Apr 23, 2:09 pm, tobie <tobie.lan...gmail.com> wrote:
> you cannot use single quotes around attributes in
HTML.
>
> Try it again with double quotes and see if you still
have the weird
> href escaping issue.
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


Re: Firefox mangling href in innerHTML
user name
2007-04-23 14:06:50

On Apr 23, 2007, at 12:09 PM, tobie wrote:

> you cannot use single quotes around attributes in
HTML.

'Tis not so:
"... attribute values be delimited using either double
quotation  
marks (ASCII decimal 34) or single quotation marks (ASCII
decimal  
39)... .
"In certain cases, authors may specify the value of an
attribute  
without any quotation marks." [1]

[1] http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2

> On Apr 23, 2:06 pm, "Steve T."
<kookn...gmail.com> wrote:
>> I would expect the alert() to spit out *EXACTLY*
what is inside the
>> <div>.  In fact that is what I get with IE7. 
However, with Firefox I
>> get --
>>
>> <a id="#"
href="#%7Bid%7D">ss#ss</a><span
id="#{id"'></span>.
>>
>> Notice two things --
>>
>> (1) The attributes are now double-quoted instead of
single-quoted.  I
>> don't think this is a big deal, but it's curious in
any case.
>>
>> (2) The original href='#' now has the 
encoded.  That
>> causes a problem when I try to use this string in a
Prototype
>> Template.  I've been fooling around with this a bit
and the only
>> attribute on any HTML element that I can find that
does this is the
>> href inside an <A />.

Steve: As you point out, Firefox "normalizes" text
it parses when  
creating its internal DOM tree. The HTML 4.01 spec says the
attribute  
of href must be of type URI [2] [3], which is likely why
Firefox  
changes the value--it's an effort to be standards
compliant.

[2] http://www.w3.org/TR/html401/struct/links.html#h-12.2
[3] http://www.ietf.o
rg/rfc/rfc2396.txt


TAG

>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffsgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=
en
-~----------~----~----~----~------~----~------~--~---


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )