Connecting Tech Pros Worldwide Forums | Help | Site Map

Get maximium width and height of the screen

Newbie
 
Join Date: Feb 2007
Posts: 8
#1: Feb 16 '07
Hi all, i want to get the maximum width and height of the screen. could anyone telll me the right coding for this

Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#2: Feb 16 '07

re: Get maximium width and height of the screen


I'm not sure if you can do that with php.

PHP is run server side so it only gets limited info about the client. Browser type and such.

I would consider using javascript for this kind of thing.
Newbie
 
Join Date: Jul 2006
Posts: 14
#3: Feb 16 '07

re: Get maximium width and height of the screen


yes you are right we can't do in php use javascript

check the below code

part1-javascript

[HTML]<script type="text/javascript">

width = screen.width;
height = screen.height;

if (width > 0 && height >0) {
window.location.href = "http://localhost/main.php?width=" + width + "&height=" + height;
} else
exit();

</script>
[/HTML]

part-2 php (main.php)
[PHP]
<?php
echo "<h1>Screen Resolution:</h1>";
echo "Width : ".$_GET['width']."<br>";
echo "Height : ".$_GET['height']."<br>";
?>[/PHP]

I hope this would solve the problem
Newbie
 
Join Date: Feb 2007
Posts: 8
#4: Mar 2 '07

re: Get maximium width and height of the screen


Thank a lot. its working....
Reply


Similar JavaScript / Ajax / DHTML bytes