如果窗口大小为300x500,则打开页面else重定向php代码


if window size is 300x500 then open page else redirect php code

我需要一些php代码,它有一个定义的窗口大小,如果大小为true,如果不重定向到另一个页面,则运行该页面。我将使用iframe管理窗口大小。php有可能吗?如果没有,还有别的办法。

这是一个小javascript,它检查宽度和高度,如果不是您指定的位置,则设置文档位置,但它正在从php中得到响应。您可以使用maxheight、maxwidth和url变量。

<?php 
 $jssnippet = "<script type='text/javascript'>var width = window.innerWidth; 
 var height= window.innerHeight; 
 var maxheight=480; 
 var maxwidth=360;
 var redirecturl='http://www.xl21.org';
 if((width>maxwidth) && (height>maxheight)){document.location=url; }</script>"; 
echo $jssnippet;
?>

PHP不可能知道窗口大小。

这是JavaScript的任务。

使用JS 获取窗口大小的示例