Apply background color after window loads completely
I'm calling the openLogo
function on a button click. A new window opens and displays the logo. Some of my logos are white in color, so after the window opens I need to change the background color of the window so that the white logo is visible. The background color of the window that is opening is displaying in a different color(light grey) as expected in IE, but in Firefox the background color flashes for a second and disappears. I think the background color is applied even before the page loads fully. Is there a way to apply background color after the new pop up window loads fully so that I could see the background color as light grey in firefox as well?
function openLogo(){
if(document.getElementById("whiteRadio").checked){
myWindow = window.open(logoMap[version + "-" + where + "-" + size + "-" + color + "-" + symbol]);
myWindow.document.bgColor="lightgrey";
}
else {
myWindow = window.open(logoMap[version + "-" + where + "-" + size + "-" + color + "-" + symbol]);
}
}
Thanks. The updated code is:
function openLogo(){
if(document.getElementById("whiteRad开发者_如何学Pythonio").checked){
var logosrc = "https://" + document.location.hostname + logoMap[version + "-" + where + "-" + size + "-" + color + "-" + symbol];
var w = window.open(logoMap[version + "-" + where + "-" + size + "-" + color + "-" + symbol]);
w.document.writeln("<body>");
w.document.writeln("<div style=background-color:#DEDEDE><img src='" + logosrc + "'><\/div>");
w.document.writeln("<\/body>");
w.document.close();
}
else {
myWindow = window.open(logoMap[version + "-" + where + "-" + size + "-" + color + "-" + symbol]);
}
}
Put some script in the pop-up page itself that sets its own background colour.
myWindow.document.body.bgColor="lightgrey";
精彩评论