Forum Moderators: coopster

Message Too Old, No Replies

Screen Resolution using php and javascript

Works in Firefox but not ie7

         

BobTennis

4:24 pm on Jun 22, 2007 (gmt 0)

10+ Year Member



I got the following code from this site, but it doesn't seem to work in Internet Explorer 7.

The screen stays blank when it comes up but there is some flashing message on the status line almost like its looping,(can't read it) and I also get an "unknown zone" message on the bottom right of the status line.

Does anybody have any ideas on how to make it work for ie7 also? I don't really know javascript, just copied this from elsewhere on this site. Evidently older code as I couldn't reply there!

-----------------
<HTML>
<TITLE>getting screen resolution</TITLE>
<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>

[edited by: jatar_k at 4:36 pm (utc) on June 22, 2007]
[edit reason] removed specifics [/edit]

eelixduppy

3:56 am on Jun 23, 2007 (gmt 0)



Try changing this line:

var the_cookie = the_cookie + ";expires=" + the_cookie_date;

To this:


var the_cookie = the_cookie + ";expires=" + the_cookie_date + ";path=/";

Not sure if this will help. This is definitely a Javascript problem, though, so you will probably have a better time over there: Javascript Forum [webmasterworld.com].

Good luck and Welcome to WebmasterWorld! :)