Welcome to WebmasterWorld Guest from 50.16.24.12

Forum Moderators: coopster & jatar k

Detect screen resolution using PHP

   
8:52 am on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, I just got this code that detects screen resolution and put them to good use for PHP program. My question: Does this program refresh the browser once before showing the screen resolution? If so, will that count as two page views by most javascript-based traffic tracker?

Thanks much!

<HTML>
<TITLE>PHPBuddy getting screen resolution</TITLE>
<!--
(c) [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>

9:59 am on Aug 11, 2004 (gmt 0)

10+ Year Member



Does this program refresh the browser once before showing the screen resolution?

Yes.

If so, will that count as two page views by most javascript-based traffic tracker?

If on the first page-request (that writes the cookie, then refreshes), you never output the tracker-Javascript, then it won't get counted twice.

Q: What happens when a user views this page, who has Cookies disabled... ;)

9:39 pm on Aug 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm no expert... but will this function keep enter an endless loop if someone's browser cookie is disabled?
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month