Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
September 02, 2014, 06:12:50 PM

Pages: [1]   Go Down
  Print  
Author Topic: how to detect scren resolution  (Read 4766 times)
chelsea
Trekkie
**
Offline Offline

Posts: 10


« on: February 12, 2013, 04:30:44 PM »

How can I use javascript to detect  screen resolution
Logged
tcl
Spacescooter Operator
*****
Offline Offline

Posts: 32


« Reply #1 on: April 26, 2013, 02:59:38 AM »

window.screen.availHeight
window.screen.availWidth 
Logged
annaharris
Spacescooter Operator
*****
Offline Offline

Posts: 49


WWW
« Reply #2 on: May 27, 2013, 04:09:17 AM »

Try:
var width = screen.width;
var height = screen.height;
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Online Online

Posts: 5871



« 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.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Pages: [1]   Go Up
  Print  
 
Jump to: