How to change background color in IE9

IE9 pop-ups have a black background when displaying a PNG image. I found a workaround that works on Firefox 10 (and above) that also shows PNG with a dark background in a popup. Here is the code, this does not work for IE9:

function openLarge() {
    var image = $('main-image').href;
    NewWin = window.open(image,"LargeImage","resizable=yes,scrollbars=auto,status=no,width=710,height=510");
    NewWin.document.writeln("<body bgcolor='#fff'>");
    NewWin.document.writeln("<img src='" + image + "'>");
    NewWin.document.writeln("<\/body>");
    NewWin.document.close();
}

Any ideas?

+3
source share
1 answer

The problem here is with the opening address. If you delete the link imageand open a blank document, you will have a background set.

I suspect this is due to the headers on the first load of the resource. With the image, the type of content will matter image/jpegor something else, but then we try to manipulate the document as if it were text/html.

function openLarge() {
    var image = $('main-image').href;
    NewWin = window.open('',"LargeImage","resizable=yes,scrollbars=auto,status=no,width=710,height=510");
    NewWin.document.writeln("<body bgcolor='#fff'>");
    NewWin.document.writeln("<img src='" + image + "'>");
    NewWin.document.writeln("<\/body>");
    NewWin.document.close();
}
+3
source

All Articles