Js to obtain the computer resolution of the idea and operation
- 2020-03-29 23:58:06
- OfStack
When making a page, the user requires different resolutions and different positions of the popup window. I wonder if I can get the screen width first, then pay the value to the variable, and then set the parameters in onclick
This code displays different pages on different screens
Here's what passes this parameter
<script>
alert(screen.width+"*"+screen.height)
</script>
<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 =" Page visible area width: "+ document.body.clientWidth;
s+="rn High visibility area: "+ document.body.clientHeight;
s += "rn Full text width: "+ document.body.scrollWidth;
s += "rn Full text of the web page: "+ document.body.scrollHeight;
s += "rn On the body of the page: "+ window.screenTop;
s += "rn Page body part left: "+ window.screenLeft;
s += "rn High screen resolution: "+ window.screen.height;
s += "rn Width of screen resolution: "+ window.screen.width;
s +="rn Screen available workspace height: "+ window.screen.availHeight;
s +="rn Screen available workspace 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 page accordingly */
var url800x600 = "index1.asp";
var url1024x768 = "index2.asp";
if (screen.width <= 800 )
window.location.href= url800x600;
else if ((screen.width >= 1024) )
window.location.href= url1024x768;
}
// End -->
</script>
This code displays different pages on different screens
Here's what passes this parameter
<script language=JavaScript>
document.write("<a href='WebStat/index.asp'>");
document.write("<img src='WebStat/count.asp?Referer=<%=refer%>
&Width="+escape(screen.width)+"&Height="+escape(screen.height)+
"' border=0 width=1 height=1>");
document.write("</a>");
</script>