ok, so this is weird.
the following code works in all browsers, except in IE9 when chaning it to IE8 in the developer tools.
var img = $('<img/>').load(function (e) {
$('.md').append(e.target);
}).attr({ 'id': 'imgprofile', 'src': "http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/HelloWorld.svg/512px-HelloWorld.svg.png", 'style': 'border:2px solid #a8a7a7;' });
here is an example:
http://jsfiddle.net/RZeY5/5/
as you can see, when the .load event is completed (only in IE8 Mode)
instead of adding the image to dom, something happens and the whole screen goes white (in the jsfiddle example, the iframe is going white).
after spending hours and hours on trying to understand whats wrong with my code (this is a very long JS file….)
i managed to take it down to the $('.md').append(e.target); line but i do not know what to do now…
is this my fault? is this JQuery fault? is it IE8 fault?
what can i do to solve this issue?
please notice, you MUST be in IE8 mode for the ‘bug’ to happen.
EDIT **
i just so that it happens also in IE7 mode…
In those IEs, the
e.target === documentande.targetis not appropriate anyway, you should usee.currentTargetorthis.http://jsfiddle.net/RZeY5/7/
Those older IEs use
srcElement, which happens to benullin this case and jQuery assigns it todocumentin this case.