Thursday, April 29, 2010

input.value vs. input.getAttribute("value")

Just quick obervation:

HTML comes to client with server side value
"input value='orig'.
Now let's dump
i.value and i.getAttribute("value")
in window.onload handler.

results:
MSIE 7.0: orig, orig
FF: 3.5.6: orig, orig
as expected both values reflect the data sent from server inside value attribute.

Now, change value by typing to "new" text.
Click refresh (or navigate away and back).

You should read "new" in the field (if browser remembers).
All fine:

Now look at the dump from onload handler:

MSIE 7.0: new, new
FF: new, orig

In msie the original HTML markup value is not accessible (lost ?)
by getAttribute after return to the page.

TODO: test the others, find explanation

No comments:

Post a Comment