请注意,我们中的一些人喜欢我们的浏览器非最大化.也许你最好不要试图检测浏览器大小而不是屏幕分辨率.我假设要做的任何一个JS都非常相似,但我实际上并不知道是这样的.
另外,盲人的屏幕阅读器的分辨率是多少?
您必须将 PHP 与 JavaScript 一起使用,如下例所示:
$url = $_SERVER['PHP_SELF'];
if( isset($HTTP_COOKIE_VARS["res"]) )
$res = $HTTP_COOKIE_VARS["res"];
else {
?>
<script language="javascript">
<!--
go();
function go()
{
var today = new Date();
var the_date = new Date("August 31, 2020");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
location = '<?echo "$url";?>';
}
//-->
</script>
<?php
}
//Let's "split" the resolution results into two variables
list($width, $height) = split('[x]', $res);
//Take the width and height minus 300
$tb_width = $width-300;
$tb_height = $height-300;
//Make the table
print("<table align=center border=1 width=" .$tb_width . " height=" . $tb_height . " >
<tr><td align=center>Your screen resolution is " . $width . " by " . $height . ".<br>
The width/height of this table is " . $tb_width . " by " . $tb_height . ".</td></tr>
</table>");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
43295 次 |
最近记录: |