screen size

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

screen size

Post by gavinbsocom »

Is there a function or method or w/e in php that determines the screen size of a persons monitor whether its 1024 x 768 or 800 x 600 ? and if so, does it load a different page? and if so do you need to make 2 seperate pages? or something?
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

PHP can't do it. Javascript can. Javascript + PHP could also do it together, but if you're already reliant on js you might as well finish the job.

Depending on your content, you'd either build two different versions of the pages (ick) or two different style sheets.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

grab the java script code, it's easily availible online, google around for a good one.

then transfer the variable to a php switch page

Code: Select all

<?php
$screensize = ""; // insert js variable here
switch ($screensize){
 case "800x600":
    header ("whatever.php");
 break;
}
// continue for other sizes
?>
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Not saying that Sami is wrong in any way but I would use a session variable and set it to the resolution. This way you would not need whatever800.php and whatever1024.php and the resolution would be easily passed through your entire site.

Of course, if someone changes their resolution mid session then there would be a problem. But I am sure not many people would do that.
User avatar
cybaf
Forum Commoner
Posts: 89
Joined: Tue Oct 01, 2002 5:28 am
Location: Gothenburg Sweden

Post by cybaf »

the use of different stylesheets as suggested above would be the "best" solution. that way you would not need different versions of your html/php code and no session that _could_ possibly not work when a user changes resolution.. :)

//cybaf
Post Reply