Unstoppable Domains

PHP Screen Resoloution

Spaceship Spaceship
Watch

dc1pop

VIP Member
Impact
13
Hi guys,

Im a newb to PHP and was wondering if it was possible to find a users screen resolution out via PHP and then depending on the result set a variable to a certain value.

For example if the users screen res is 800x600 or lower set the variable xx template and for 1024x768 or higher set the variable to xx template.

Hope someone has an idea :)

Thanks,
Darren

-----------

Just read up and it see's doing this is a bad idea?
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
•••
^ can't get it w/PHP, but w/JavaScript :)
 
0
•••
Thanks guys,

However would it be a bad idea?

Ive read a few bits about it and people sugest not to do it. The only thing i wish to do is to drop a few bits out the template that are not 800x600 friendly on my arcade. Like the bar on the right hand side on game pages which makes the user have to scroll.

Only reason im consered is my stats show 20% of my visitors are using that resolution and i want them to view the site easier then having to scroll etc.
 
0
•••
This is an example of how it can be done from phpbuddy.com - Its not a bad idea, however if the user has disabled cookies it may not function correctly.

PHP:
<HTML>
<TITLE>PHPBuddy getting screen resolution</TITLE>
<!--
(c) http://www.phpbuddy.com (Feel free to use this script but keep this message intact)
Author: Ranjit Kumar (Cheif Editor phpbuddy.com)
-->
<HEAD>
<?
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
	$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();

function writeCookie() 
{
 var today = new Date();
 var the_date = new Date("December 31, 2023");
 var the_cookie_date = the_date.toGMTString();
 var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
 var the_cookie = the_cookie + ";expires=" + the_cookie_date;
 document.cookie=the_cookie
	 
 location = 'get_resolution.php';
}
//-->
</script>
<?
}
?>
</HEAD>
<BODY>
<?php
	echo "Your Screen resolution is set at ". $screen_res;
?>
</BODY>
</HTML>
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back