How does php obtain the client computer screen parameters (width, height, resolution)

Source: Internet
Author: User
Tags php server

The first thing to note is that php is a server-side language and cannot obtain the width and height of the client screen. However, the work und is to use the client scripting language javascript to obtain the width and height of the client's computer screen, and then pass it to the php scripting language in the form of ajax or cookie, in this way, php can obtain the screen width and height of the client computer.

You can use javascript to obtain the width, height, and resolution of the client computer as follows:

Screen resolution height: window. screen. height

Screen resolution width: window. screen. width

Available screen workspace height: window. screen. availHeight

Available workspace width: window. screen. availWidth

The method passed to the php server is as follows:

The code is as follows: Copy code
$. Post ('http: // www.phpernote.com/php-template-framework/189.html', expires w:width,h:height}); // the returned value is ignored here

The complete code for obtaining the width, height, and resolution of the display screen on the client computer using php is as follows:

The code is as follows: Copy code
<Html xmlns = "http://www.phpernote.com/javascript-function/34.html">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = utf-8"/>
<Title> Untitled Document </title>
<Script type = "text/javascript" src = "http://www.phpernote.com/js/jquery.min.js"> </script>
<Script type = "text/javascript">
$ (Function (){
Var width = window. screen. height;
Var height = window. screen. width;
$. Post ('http: // www.phpernote.com/php-template-framework/189.html', {w:width,h:height}); // input relevant parameters to your statistics file.
});
</Script>
</Head>
<Body>
Here is the body ......
</Body>
</Html>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.