Detecting users screen size and resolution - javascript

by Francis 2014-04-12 10:35:27

Detecting users screen size and resolution
Find your device width and height resolution using Javascript


<?php

if(isset($_COOKIE["deviceResolution"]))
{
$urScreenRes = $_COOKIE["deviceResolution"];
}
else //cookie is not found set it using Javascript to get screen width and height
{
?>
<script language="javascript">

checkScreenRes();

function checkScreenRes()
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + 365);
var screenWidth = screen.width +"x"+ screen.height;
var c_value=screenWidth + "; expires="+exdate.toUTCString();
document.cookie= 'deviceResolution=' + c_value;
}

</script>
<?
}

echo "Your screen resolution is ". $urScreenRes;
?>
1104
like
0
dislike
0
mail
flag

You must LOGIN to add comments