|
【摘 要】
如何显示浏览者的屏幕分辨率的PHP代码?下面是代码整个过程,希望大家提出不同意见。
先新建一个文件,取名:resolution.php;代码的内容如下:(文件的扩展名必须是.PHP)
<script language="javascript">
<!--
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_res="+ screen.width +"x"+
screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
location = '';
}
function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>
<script language="javascript">
<!--
checkRes(1024, 768);
//-->
</script>
其次把下面的代码放到你想在哪显示访客的显示器分辨率信息的地方就可以了!
<?php
$callget_res_page_name = $REQUEST_URI;
$GLOBALS[callget_res_page_name ] = $callget_res_page_name;
include("resolution.php");
echo $screen_width."x".$screen_height." is your
screen resolution.";
?>
注意:$应该是半角
|