amplesdk icon indicating copy to clipboard operation
amplesdk copied to clipboard

<img /> with @src does not work in IE9

Open tedbeer opened this issue 12 years ago • 1 comments

If img is created from string it does not load content in IE9. The following code works in FF, Chrome, IE10 but not in IE9 (standard mode):

ample.query('<img src="icon.png" />').appendTo(ample.documentElement);

tedbeer avatar Apr 03 '13 09:04 tedbeer

As workaround I modified xhtml.js - added DOMNodeInsertedIntoDocument handler

cXHTMLElement_img.handlers = {
    "DOMNodeInsertedIntoDocument":  function(oEvent) {
        var aIE = window.navigator.userAgent.match(/MSIE\s(\d+\.\d+)/),
            bIE9 = aIE && (1 * aIE[1] == 9);
        if (bIE9 && this.hasAttribute('src')){
            var oThis = this;
            (function waitState() {
                var img = oThis.$getContainer(),
                    st = img.readyState;
                if (st == 'uninitialized') {
                    img.src = '';
                    img.src = oThis.getAttribute('src');
                    setTimeout(waitState, 250);
                }
            })();
        }
    }
};

tedbeer avatar Apr 05 '13 12:04 tedbeer