Sorry I's late because I have a examination tomorrow!ft~~~,just try this~! <?php if (isset($_GET['width']) AND isset($_GET['height'])) { // output the geometry variables echo "Screen width is: ". $_GET['width'] ."<br />\n"; echo "Screen height is: ". $_GET['height'] ."<br />\n"; } else { // pass the geometry variables // (preserve the original query string // -- post variables will need to handled differently) echo "<script language=\"javascript\">\n"; echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&width=\" + screen.width + \"&height=\" + screen.height;\n"; echo "</script>\n"; exit(); } ?>
It's too late and I'm going to bed!See you tomorrow !
alert ('分辨率为 ' + screen.width + '×' + screen.height );
</script>
";
给个例子而已,你可以按实际应用
<?php
function hope1983()
{
echo "<script language=javascript>
alert ('分辨率为 ' + screen.width + '×' + screen.height );
</script>
";
}
$width=hope1983();
echo $width; //输出?>
<script language=javascript>
alert ('分辨率为 ' + screen.width + '×' + screen.height );
</script>不用写那段PHP程序了,我感觉只能通java来实现,在客户端生成一个页后java测到数值,赋给text,然后客户端再提交回服务,也许这样可以实现
PHP在服务器端运行,JS在客户端运行,PHP的值可以让JS调用,JS的值除了用表单提交,怎么可能让PHP调用呢。
<?php
if (isset($_GET['width']) AND isset($_GET['height'])) {
// output the geometry variables
echo "Screen width is: ". $_GET['width'] ."<br />\n";
echo "Screen height is: ". $_GET['height'] ."<br />\n";
} else {
// pass the geometry variables
// (preserve the original query string
// -- post variables will need to handled differently) echo "<script language=\"javascript\">\n";
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
. "&width=\" + screen.width + \"&height=\" + screen.height;\n";
echo "</script>\n";
exit();
}
?>
document.write(window.screen.width);
document.write(window.screen.height);
</script>
{
echo <<<EOT
<script language="javascript">
echo "<script language=\"JavaScript\">
w = window.screen.width;
h = window.screen.height;
self.location=self.location+\"?width=\"+w+\"&height=\"+h;</script>";
</script>
EOT;
exit();
}
?width=***&height=***也是怪怪的。