> I figured it out.  I was wiping out the form by setting the innerHTML
> property of a parent div before calling form.serialize.  Interestingly
> though, this worked in previous versions of IE and still does in
> virtually every other browser, if you have a reference to the form
> before wiping it out.

If you have a reference to the form's DOM element prior to setting
`innerHTML`, it should remain valid. I found it so surprising that IE8
would get this wrong that (with apologies) I had to test it for
myself. But I can easily replicate your result on IE6 - IE9:

http://jsbin.com/elihi5

It only happens if you remove the form by setting `innerHTML` on its
parent, though. If you remove it via DOM `removeChild`, it works
correctly:

http://jsbin.com/elihi5/2

So it's down to how IE handles setting `innerHTML`. Apparently, doing
so destroys the parent/child relationship of the elements therein, as
we can see here:

http://jsbin.com/elihi5/5

If I use `innerHTML` to clear it, although my reference to the form
remains valid, the form no longer has any children. If I already have
a reference to one of its children, my reference remains valid, but
the form still loses that child.

Very surprising behavior. I suppose since `innerHTML` is a Microsoft
invention and hasn't until recently[1] been subject to any
standardization, calling this "wrong" (as I did above) is harsh. But
really, really surprising.

Thanks for letting us know about it!

[1] http://www.w3.org/TR/html5/apis-in-html-documents.html#dom-innerhtml
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Jun 16, 12:07 am, Don <donlope...@gmail.com> wrote:
> On Jun 15, 2:25 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
>
> > Hi,
>
> > On Jun 14, 5:40 pm, Don <donlope...@gmail.com> wrote:
>
> > > form.serialize in IE8 is returning a blank string, even though there
> > > are elements.  Should this be working in IE8?
>
> > That seems really unlikely. What does your form look like? And in
> > particular, do the form fields have `name` values (rather than `id`s)?
>
> I figured it out.  I was wiping out the form by setting the innerHTML
> property of a parent div before calling form.serialize.  Interestingly
> though, this worked in previous versions of IE and still does in
> virtually every other browser, if you have a reference to the form
> before wiping it out.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to