homepage Welcome to WebmasterWorld Guest from 54.163.70.249
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Detect screen resolution using PHP
irock




msg:1286417
 8:52 am on Aug 11, 2004 (gmt 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>

 

ruserious




msg:1286418
 9:59 am on Aug 11, 2004 (gmt 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... ;)

irock




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved