php获取客户端屏幕宽度、高度及分辨率的方法

WBOY
Release: 2016-06-20 13:04:29
Original
2988 people have browsed it

php获取客户端屏幕宽度、高度及分辨率的方法

php获取客户端屏幕宽度、高度及分辨率的方法

首先需要说明的是php是服务器端的语言,是获取不到客户端的屏幕的宽度和高度以及分辨率的的。但是有变通的方法就是通过客户端脚本语言javascript获取客户端的屏幕的宽度和高度,然后通过ajax或者cookie的形式传递给php脚本语言,从而实现php获取客户端屏幕宽度和高度的办法。

通过javascript获取客户端电脑的宽度,高度,分辨率的方法如下:

屏幕分辨率的高: window.screen.height

屏幕分辨率的宽: window.screen.width

屏幕可用工作区高度: window.screen.availHeight

屏幕可用工作区宽度: window.screen.availWidth

具体实例:

<p><script type="text/javascript"></p><p>$(function(){</p><p>    var width=window.screen.height;</p><p>    var height=window.screen.width;</p><p>    var awidth=window.screen.availHeight;</p><p>    var aheight=window.screen.availWidth;<br /></p><p>    $.post('get_info.php',{w:width,h:height,aw:awidth,ah:aheight});</p><p>//这里向你的统计文件里面传入相关的参数</p><p>});</p><p></script></p>
Copy after login



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!