Screen resolution

Any problem with PHP can be disscused here
Post Reply
tanaka
Posts: 195
Joined: Sat Mar 05, 2005 5:27 pm

Screen resolution

Post by tanaka »

Is it possible to take info about user's screen resolution, put it on a variable and do something as

if($screen==800x600){
do something}
else{
do other thing}

?


L O L
Lixas
Posts: 750
Joined: Wed Feb 16, 2005 4:21 pm

Post by Lixas »

yes, it is possible, but not with php. U should use client side scripting language- javascript:

Code: Select all

<SCRIPT language="JavaScript">
<!-- this javascript code is right, but i dont say exactly same about syntax. Review it if it will not work

window.location='resolution.php?w='+screen.width+'&h='+screen.height; 

//-->
</SCRIPT>
in page resolution.php u will have global variables $w and $h with screen resulution
Browser Compatibility: NS 4+, IE 5+, Firefox

Taken and edited from http://www.pageresource.com/jscript/jscreen.htm
Image
tanaka
Posts: 195
Joined: Sat Mar 05, 2005 5:27 pm

Post by tanaka »

Wow, that's nice stuff.
Thanks Lixas
L O L
Lixas
Posts: 750
Joined: Wed Feb 16, 2005 4:21 pm

Post by Lixas »

no problem, i allways help then i can. It's nice, that i can help with my coding knowledge for someone....
Image
toychoq
Posts: 108
Joined: Fri Apr 15, 2005 9:11 am

Post by toychoq »

Why need to set screen resolution
mzikawy
Posts: 111
Joined: Wed Jan 18, 2006 1:01 am
Contact:

Post by mzikawy »

Thnx man it's really useful one
The Life is a very Big surprise ... Try to believe it .
Lixas
Posts: 750
Joined: Wed Feb 16, 2005 4:21 pm

Post by Lixas »

toychoq wrote:Why need to set screen resolution
Not to set screen resulotion, but to know it. I think you understood wrong. php natively can not obtain user's screen's resolution, but using javascript you can pass it to page via $_GET method if you will need. It's sometimes usefull
Image
kaos_frack
Posts: 504
Joined: Sat May 07, 2005 8:03 am
Contact:

Post by kaos_frack »

toychoq wrote:Why need to set screen resolution
you really need to know
ex. to make sure the width fits the resolution
otherwise users hate scrolling
so they'll just close your page, and never return again
Post Reply