views:

2191

answers:

4

Hi,

I want to detect users' screen size and pass this into a charting application (Chart Director by http://www.advsofteng.com) to control how big an image to display.

I have to use ASP, but I can only think to use JavaScript to detect screen-size and then pass this into the server-side script. Is there an easier way?

Thanks

+2  A: 

Here's a couple of links that should help

http://www.javascriptkit.com/howto/newtech3.shtml

http://www.devcity.net/Articles/64/1/screenresolution.aspx

EvilEddie
Thanks - hadn't realised existence of availHeight and availWidth
Dan W
+4  A: 

No, the server knows nothing about the client other than basic info like IP and browser version. Screen resolution can easily be determined via javascript and passed to the server though, using ajax, or via form submission.

Kolten
A: 

No, this is not possible for desktop browsers. I suggest embedding an image that's appropriate for typical screen resolutions, then detecting the canvas size, and rewriting the image's src attribute to reflect that.

In any case, you don't want to look at the screen resolution, you want to look at the canvas size. Not everybody uses their browser with a maximised window, especially those with large screens. If you use the screen resolution, then you'll end up serving images that are way too big for some people.

Jim
A: 

You can't get the users screen size only the browser window size, and thats doable using javascript.

Omar Kooheji
incorrect. See the link that Phunchak posted (1st one)
Kolten