I'm having a problem with setting a background image depending on viewer's resolution. It works fine in IE 6 and Opera 7, but not in Netscape 7 or Firefox 1.0, at least not when the resolution is 800 x 600 (it still displays the 1024 graphic.)
Here's my code:
Anyone know what the problem is? Thanks,
Here's my code:
Code:
<script>
function changeBkg(){
var b = document.getElementById('body');
var scrw = screen.width;
var scrh = screen.height;
if ((scrw >= 1024) && (scrh >= 768)){
alert(">= 1024");
b.style.background="url('1024-768.jpg')";
}
else{
b.style.background="url('800-600.jpg')";
alert("<1024");
}
}
</script>
... and in the body tag:
<body onLoad="changeBkg()" id="body">
Anyone know what the problem is? Thanks,