window.screenLeft:window.screenX,window.innerWidth,screen.width,screen.availWidth

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>window.innerWidth  window.screenLeft:window.screenX  </title>
</head>
<body>

<p id="demo"></p>
<p id="demo1"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<p id="demo4"></p>
<script>
//只读整数。声明了窗口的左上角在屏幕上的的 x 坐标和 y 坐标。IE、Safari 和 Opera 支持 screenLeft 和 screenTop,而 Firefox 和 Safari 支持 screenX 和 screenY。
var leftPos=(typeof window.screenLeft=="number")?window.screenLeft:window.screenX;
var topPos=(typeof window.screenTop=="number")?window.screenTop:window.screenY;
//window.screenLeft火狐不支持undefined,火狐得使用window.screenX
//window.screenX ie不支持undefined,ie得使用window.screenLeft



//每个浏览器对这两个数据的解析不一样




document.getElementById("demo").innerHTML=leftPos+"</br>"+topPos+"</br>";
//window.moveTo(100,100);
alert(window.innerWidth);
alert(document.documentElement.clientWidth);
alert(document.body.clientWidth);

// window.innerWidth	与或出来最大值
alert(window.innerWidth|| document.documentElement.clientWidth|| document.body.clientWidth);
var w=window.innerWidth  || document.documentElement.clientWidth  || document.body.clientWidth; 
document.getElementById("demo1").innerHTML ="window.innerWidth|| document.documentElement.clientWidth|| document.body.clientWidth:"+w;
//每个浏览器对这两个数据的解析不一样
alert(window.innerHeight);
alert(document.documentElement.clientHeight);
alert(document.body.clientHeight);

//window.innerHeight 与或出来最大值
alert(window.innerHeight|| document.documentElement.clientHeight|| document.body.clientHeight);
var h=window.innerHeight || document.documentElement.clientHeight  || document.body.clientHeight;     
document.getElementById("demo2").innerHTML = "window.innerHeight|| document.documentElement.clientHeight|| document.body.clientHeight" + h;



//每个浏览器对这两个数据的解析不一样




//Internet Explorer 8,7,6,5:document.documentElement.clientHeight要么document.body.clientHeight浏览器窗口(浏览器窗口)不包括工具栏和滚动条。

//window.screen对象可以在没有窗口的前缀被写入,该window.screen对象包含了用户的屏幕信息.
//screen.width属性返回访问者的像素屏幕的宽度.
//该screen.availWidth属性返回访问者的屏幕的宽度,以像素为单位,减去界面功能,如Windows任务栏上。
document.getElementById("demo4").innerHTML =
"Screen Width: " + screen.width+"</br>"
+"Screen Height: " + screen.height+"</br>"
+"Available Screen Width: " + screen.availWidth+"</br>"
+"Available Screen Height: " + screen.availHeight+ "</br>";



//每个浏览器对这两个数据的解析一样




</script>

</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值