Web Hosting Forum | Lunarpages

Author Topic: how to detect scren resolution  (Read 6506 times)

Offline chelsea

  • Trekkie
  • **
  • Posts: 10
how to detect scren resolution
« on: February 12, 2013, 04:30:44 PM »
How can I use javascript to detect  screen resolution

Offline tcl

  • Spacescooter Operator
  • *****
  • Posts: 30
Re: how to detect scren resolution
« Reply #1 on: April 26, 2013, 02:59:38 AM »
window.screen.availHeight
window.screen.availWidth 

Offline annaharris

  • Spacescooter Operator
  • *****
  • Posts: 48
    • PHP Development Comapny
Re: how to detect scren resolution
« Reply #2 on: May 27, 2013, 04:09:17 AM »
Try:
var width = screen.width;
var height = screen.height;

Offline MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6205
Re: how to detect scren resolution
« Reply #3 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.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

 

Share |