Welcome to WebmasterWorld Guest from 54.146.217.179

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Detect screen resolution using PHP

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 2, 2002
posts:1099
votes: 0


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)

Junior Member

10+ Year Member

joined:Oct 26, 2002
posts:173
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 2, 2002
posts:1099
votes: 0


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members