window.screen.width
window.screen.height

解决方案 »

  1.   

    echo "<script language=javascript>
      alert ('分辨率为 ' + screen.width + '×' + screen.height );
    </script>
    ";
      

  2.   

    那如何能把用js得到的分辨率赋值给一个php变量呢?将screen.width得值赋给$width.
      

  3.   

    这是弹出判断用户端浏览器的分辨率的变量$width
    给个例子而已,你可以按实际应用
    <?php
    function hope1983()
    {
    echo "<script language=javascript>
      alert ('分辨率为 ' + screen.width + '×' + screen.height );
    </script>
    ";
    }
    $width=hope1983();
    echo $width;    //输出?>
      

  4.   

    楼上不行,只能弹出来一个提示窗,但是在网页并没有输出$width
      

  5.   

    你这样作,那个分辨率还是没有赋给应该的变量,你的这段代码和没有写一样,直接这样就也是一样的
    <script language=javascript>
      alert ('分辨率为 ' + screen.width + '×' + screen.height );
    </script>不用写那段PHP程序了,我感觉只能通java来实现,在客户端生成一个页后java测到数值,赋给text,然后客户端再提交回服务,也许这样可以实现
      

  6.   

    是的,想在网页上显示,只要可以作为变量用就可以了,我找这方面的东东找了好长时间了,也没人给我说我有一个想法不知道行不行就是用java测到ie分辨率,然后让这个网页自动转到一个网址,如:http://...../xxx.php?w=800&h=600能实现吗?我对java不是很明白
      

  7.   

    汗,原来是这样.
    PHP在服务器端运行,JS在客户端运行,PHP的值可以让JS调用,JS的值除了用表单提交,怎么可能让PHP调用呢。
      

  8.   

    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();
    }
    ?>
      

  9.   

    It's too late and I'm going to bed!See you tomorrow !
      

  10.   

    <script language=javascript>
    document.write(window.screen.width);
    document.write(window.screen.height);
    </script>
      

  11.   

    if(empty($_GET["width"])||empty($_GET["height"]))
    {
    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();
    }
      

  12.   

    thunderx(平生一笑) 的方法很有用,但是用这种方法,URL后面老是加着一个
    ?width=***&height=***也是怪怪的。