Detecting users screen size and resolution - javascript
by Francis[ Edit ] 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;
?>