jeffjeff
Dec 10th 2007, 2:08 pm
hello,
can any one explain why, in ie7 at least, clicking on the area where a button is supposed to be before the page is rendered, causes the event handler to be triggered after the page has loaded fully - allowing forward referencing in the handler code?
I tested this with a page that loads a button first and then an image. when the page is loaded and rendered, it behaves as expected: pressing the button causes the image's size to change (forward referecing the image is fine, the dom has been constructed). however, on fast connections i notice an odd scenario. After the button has been parsed but before it is rendered and before the image is parsed, clicking the area where the button will be causes the event handler to trigger after the page has fully loaded (not synchronously) and so allows the forward reference!. on slower connections, where the page is partially rendered , pressing the button before the rest of the page has loaded (the image) causes the expected forward reference error.
immediately queued timeouts (settimeout(foo(),0)) work as expected during page load, i.e. no forward referencing is allowed on fast or slow connections.
any thoughts?
cheers,
dean.
can any one explain why, in ie7 at least, clicking on the area where a button is supposed to be before the page is rendered, causes the event handler to be triggered after the page has loaded fully - allowing forward referencing in the handler code?
I tested this with a page that loads a button first and then an image. when the page is loaded and rendered, it behaves as expected: pressing the button causes the image's size to change (forward referecing the image is fine, the dom has been constructed). however, on fast connections i notice an odd scenario. After the button has been parsed but before it is rendered and before the image is parsed, clicking the area where the button will be causes the event handler to trigger after the page has fully loaded (not synchronously) and so allows the forward reference!. on slower connections, where the page is partially rendered , pressing the button before the rest of the page has loaded (the image) causes the expected forward reference error.
immediately queued timeouts (settimeout(foo(),0)) work as expected during page load, i.e. no forward referencing is allowed on fast or slow connections.
any thoughts?
cheers,
dean.