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=''#{id}'' href=''#{id}''>ss#{id}ss</a><span id=''#{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="#{id}" href="#%7Bid%7D">ss#{id}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=''#{id}'' now has the { and } 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-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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=''#{id}'' href=''#{id}''>ss#{id}ss</a><span > id=''#{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="#{id}" href="#%7Bid%7D">ss#{id}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=''#{id}'' now has the { and } 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-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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="#{id}" href="#%7Bid%7D">ss#{id}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=''#{id}'' now has the { and } 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.org/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-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 24, 4:06 am, "Steve T." <kookn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.There is no public specification for innerHTML, it is a property introduced by IE that has been widely copied. It is not consistent across browsers so don''t expect it to be. [...]> (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.innerHTML is not equivalent to "view source", it is the browser telling you its version of the markup. There are many diffrences between browsers on how they report the innerHTML of elements that have exactly the same source or have been constructed or modified using the same commands.> (2) The original href=''#{id}'' now has the { and } 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?Don''t use innerHTML. Clearlly the value you are assigning to the href attribute isn''t an href, so don''t do that. Assign the value to some other property and retrieve it using getAttribute, assign a useful value to the href attribute. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
tobie a écrit :> you cannot use single quotes around attributes in HTML.AAMOF, you can, although I despise it. HTML derives from SGML, which allows both quotes [1]. XHTML relies on XML syntax rules, which also does [2]. But yeah, I hate single quotes in markup. [1] http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2 [2] http://www.w3.org/TR/REC-xml/#sec-common-syn -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---