程序|分辨率|显示
本教程属于原创,转载请注明网页教学网
今天给大家做出了一个能显示浏览者的屏幕分辨率的PHP代码,希望大家使用 一下,有什么问题请到论坛发帖讨论。
首先新建一个文件取名为:resolution.php代码的内容如下:(注意:文件的扩展名必须是.PHP不要是.HTML)
<script language="javascript"> <br><!-- <br>function writeCookie() <br>{ <br>var today = new Date(); <br>var the_date = new Date("December 31, 2023"); <br>var the_<a style="color:#f60; text-decoration:underline;" title= "cookie" href="https://www.php.cn/zt/16004.html" target="_blank">cookie_date = the_date.toGMTString(); <br>var the_cookie = "users_res="+ screen.width +"x"+ screen.height; <br>var the_cookie = the_cookie + ";expires=" + the_cookie_date; <br>document.cookie=the_cookie <br><br>location = '';<br>} <br><br>function checkRes(width, height) { <br>if(width != screen.width || height != screen.height) { <br>writeCookie(); <br>} else { <br>return true; <br>} <br>} <br>//--> <br></script>
<script language="javascript"> <br><!-- <br>checkRes(1024, 768); <br>//--> <br></script>
//网页教学网http://www.webjx.com 网页设计师的摇篮!!
其次把下面的代码放到你想在哪显示访客的显示器分辨率信息的地方就可以了!( 下面代码当然也是放在扩展名为.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.";
?>
注意:$应该是半角。










