Thursday, April 29, 2010
input.value vs. input.getAttribute("value")
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
Thursday, April 15, 2010
WebFormViewEngine - how the MVC finds "The View"
Wednesday, April 7, 2010
XHR.onreadystatechange and exceptions
Generally it is not good idea to throw exception in event handler.
However people are lazy and bugs happen, so let's see out chances in this situation.
xhr.onreadystatechange=function(){throw new Error();}
MSIE and FF supports window.onerror event, so uncought exceptions can end up in
this global handler.
All browsers support some sort of "display JavaScript errors" but usually well hidden
as small icon on status bar (MSIE) or deeply in menus (other browsers).
Uniform handling is almost impossible. The very first idea was to rely on
window.error in MSIE an FF and call window.onerror explicitly in
other browsers (even if the browser does not support this error you can define
window.onerror=function...
and call it using window.onerror(msg,..,...) syntax.
However situation is even worse.
- FF 3.5.6 works fine, ewrror thrown, ends in window.onerror as expected.
- MSIE 7.0 NativeXHR + 200 response - works fine
- MSIE 7.0 NativeXHR + conditional request + 304 response - exception lost, window.onerror not called
- MSIE 7.0 NativeXHR + cached version not tested byt expected - exception lost, window.onerror not called
- FF 3.6 exception lost, window.onerror not called
- exception being thrown out of boundaries of the handler (eaten exception)
- even if thrown to be catched somewhere (missing window.onerror concept)