PHP Function Lookup:
PHP Quick Start
PHP Installation
PHP Articles
PHP Scripts

Top Rated Articles 

Site Related
Submit Articles/Code
Contact Us
Instant cash loans, cash advance online same day

   Home                   Article Added on: April 8, 2002
Getting Screen resolution using JavaScripts & PHP

Overview: In this article we will discuss how to get the users screen resolution.

Wouldnít it be great if you get the users screen resolution so that you could send optimized content for that particluar resolution, we can get users resolution using JavaScriptís but the problem is how do we get PHP to recognize it.

What we can do is get the users resolution using JavaScript and then set a cookie which has the users resolution, we can then access that cookie in PHP!

How can I get the users screen resoultion using JavaScript?
It's really simple I will show you the code

screen.width; //gives you the screen width
screen.height; //gives you the screen height

I will explain you the stuff with an example We will be using get_resolution.php with the help of JavaScript we will get the screen resolution and then set the screen resolution's value in a cookie named users_resolution when ever we execute the page we check with PHP to see if the cookie users_resolution is set, if it is not set we set it using JavaScript.

get_resolution.php View Sample Output

Editor: PHPbuddy also uses the same kind of code to send optimized content for different resolutions if you are at 800*600 or lower resolution set your resolution to 1024*768 and check PHPbuddy! (Be sure to reload the site after you change your resolution)

Rate this article:  Current Rating: 3.57
  Poor    Excellent     
          1     2    3    4    5


Home | Privacy Policy | Contact Us | Terms of Service
(c) 2002 - 2018 www.PHPbuddy.com Unauthorized reproduction/replication of any part of this site is prohibited.