Jeaf Gilbert
Jeaf Gilbert

Reputation: 11991

How to change pop up background color on IE9

IE9 pop up windows has black background color when showing PNG image. I found a workaround which works on Firefox 10 (and above) that also shows PNG with dark background on pop up window. Here is the code, this doesn't 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?

Upvotes: 3

Views: 728

Answers (1)

Sampson
Sampson

Reputation: 268414

The problem here is with the opening address. If you remove the image reference, and open up to a blank document, you'll have your background set.

I suspect this has something to do with the headers upon first loading the resource. With an image, the content type would be set to image/jpeg or something, but then we're attempting 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();
}

Upvotes: 3

Related Questions