The thinking and operation _javascript skill of obtaining computer resolution in JS

Source: Internet
Author: User
When making the page, the user requests, the different resolution, the pop-up window position is different, I thought is not first obtains the screen width, then pays the value to the variable, then sets the parameter in the onclick
Copy Code code as follows:

<script>
Alert (screen.width+ "*" +screen.height)
</script>

Copy Code code as follows:

<script>
function CenterWindow (url,w,h) {
L= (screen.width-w)/2
t= (screen.height-h)/2
window.open (URL, ', ' left= ' +l+ ', top= ' +t+ ', width= ' +w+ ', height= ' +h ')
}
</script>
<input Type=button onclick= "CenterWindow (' About:blank ', 200,200)" >
---------------------------------------------------------------

<body>
<script language= "JavaScript" >
var s = "Web page visible area wide:" + document.body.clientWidth;
s+= "\ r \ n page visible Area High:" + document.body.clientHeight;
s + + "\ r \ n page text full text width:" + document.body.scrollWidth;
s + + "\ r \ n" page full text High: "+ document.body.scrollHeight;
s + + "\ r \ n Page body part:" + window.screentop;
s + + "\ r \ n Page body part left:" + window.screenleft;
s + + "\ r \ n screen resolution of High:" + window.screen.height;
s + + "\ r \ n Screen resolution width:" + window.screen.width;
s + = "\ r \ n Screen available working area height:" + window.screen.availHeight;
s + = "\ r \ n Screen available working area width:" + window.screen.availWidth;
alert (s);
</SCRIPT>
---------------------------------------------------------------

<script language= "JavaScript" >
<!--Begin
function Redirectpage () {
/*var url640x480 = "http://www.yourweb.com/640x480.html"; * * Remember to change the corresponding page * *
var url800x600 = "index1.asp";
var url1024x768 = "index2.asp";
/*if ((Screen.width = = 640) && (screen.height = = 480))
window.location.href= url640x480;*/
if (screen.width <= 800)
Window.location.href= url800x600;
else if ((screen.width >= 1024))
Window.location.href= url1024x768;
}
End-->
</script>

This code shows different pages based on different screens.

The following is the parameter passed
Copy Code code as follows:

<script language=javascript>
document.write ("<a href= ' webstat/index.asp ' >");
document.write ("
&width= "+escape (screen.width) +" &height= "+escape (screen.height) +
"' Border=0 width=1 height=1>");
document.write ("</a>");
</script>

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.