Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Java script :  forum.Salix.gr forum.Salix.gr
Little scripts that might be helpful. It's more like a repository of commonly used functions. Have something you want to share? post it here!! 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messageGet screen resolution
Posted by: panos (IP Logged)
Date: June 23, 2006 03:32AM

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.



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum