Lunarpages Web Hosting Forum

Scripting Languages Hosting Help => JavaScript Support => Topic started by: chelsea on February 12, 2013, 04:30:44 PM

Title: how to detect scren resolution
Post by: chelsea on February 12, 2013, 04:30:44 PM
How can I use javascript to detect  screen resolution
Title: Re: how to detect scren resolution
Post by: tcl on April 26, 2013, 02:59:38 AM
window.screen.availHeight
window.screen.availWidth  (http://Lunarpages.com/cat/6-5/1.gif)
Title: Re: how to detect scren resolution
Post by: annaharris on May 27, 2013, 04:09:17 AM
Try:
var width = screen.width;
var height = screen.height;
Title: Re: how to detect scren resolution
Post by: MrPhil on May 27, 2013, 06:32:52 AM
Be sure to test your code on all widely-used browsers. Javascript implementations differ from engine to engine, and you may end up having to test the existence of certain variables. If they don't exist, try another variable until you get a hit.

If you need to pass this information back to the server side (PHP, etc.), you would do it in a URL Query String (on the next link back to the server) or perhaps in a session cookie of some sort. Don't forget to catch any screen resize events and such, and report them back.