To get client's screen resolution you can use screen's object properties width and height. The following will alert screen resolution.
<script>
window.alert(screen.width+' '+screen.height);
</script>
If you want those value to be passed to server side script you can simply set them to a couple of cookies. That way your server side scripts can read the values.
But be aware that you have to collect that info first and then used by server side scripts, so you must place the resolution detecting script somewhere that you are sure that the user will visit first.
In my opinion is risky to rely on resolution detection to form html or something server side. It would be better to handle it client side. Like in an example I found.
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Begin
if (screen.height >= 768 && screen.width >= 1024) {
document.write("<img src='http://your-web-site-address-here.com/imagea.jpg' width=512 height=384 border=0>");
}
else {
if (screen.height == 600 && screen.width == 800) {
document.write("<img src='http://your-web-site-address-here.com/imageb.jpg' width=304 height=204 border=0>");
}
}
// End -->
</script>
Edited 1 time(s). Last edit at 07/07/2006 09:04AM by panos.