PDA

View Full Version : what am I doing wrong?


idiotbear
05-21-2003, 02:35 PM
v new to javascript (I've always just relied on dreamweaver's built-in functions so far!), so apologies if this is ridiculously easy ;)

I'm trying to detect the user's screen depth, and if it's less than 16-bit, give them an alert. Here's my code. It doesn't work (no browser errors - it just doesn't do anything.)

<script type="text/javascript">

function depth()
{
var scrdepth=window.screen.colorDepth
if (scrdepth < 16)
window.alert("Your monitor is set to 8-bit colour, which means that this website's colours will not display properly. It is recommended that you adjust your display settings to at least 16-bit High Colour. Thank you.")
}

</script>

Then I call the function:

<body onload="depth()" etc etc...../>

Please help!

:confused:

Catman
05-21-2003, 03:34 PM
I just tried your script with IE 6.0, Netscape 6.2 and 7.0, and Opera 7.0, and it works with them all.

You are remembering to lower the color depth on your computer, yes?

idiotbear
05-22-2003, 09:03 AM
I took out the function depth() and the onload call, and just had it execute in the head tag without being called. Works fine now.

And yeah, I was remembering to lower my colour depth ;)

Cheers anyway