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
    评论
window.open()是JavaScript中常用的打开新窗口的方法。在使用该方法时,我们可以传递一些参数来定制新打开的窗口,也可以通过新打开窗口中的JavaScript代码来获取这些参数。 在window.open()中,可以设置的参数有: 1. URL:表示要在新窗口中打开的网页的URL地址。 2. name:表示新窗口的名称。 3. width:表示新窗口的宽度。 4. height:表示新窗口的高度。 5. top:表示新窗口距离系统桌面顶部的位置。 6. left:表示新窗口距离系统桌面左侧的位置。 7. menubar:是否显示菜单栏。 8. toolbar:是否显示工具栏。 9. scrollbars:是否显示滚动条。 10. location:是否显示地址栏。 11. status:是否显示状态栏。 12. resizable:是否可以改变窗口大小。 我们可以通过在window.open()中传递这些参数来定制新打开的窗口。例如: ``` window.open('https://www.baidu.com', 'newWindow', 'width=800,height=600,top=100,left=100'); ``` 此外,我们还可以通过在新打开的窗口中使用JavaScript代码来获取这些参数。例如,在新窗口中编写如下代码: ``` var url = window.opener.location.href; var name = window.name; var width = window.opener.innerWidth; var height = window.opener.innerHeight; var top = window.screenTop; var left = window.screenLeft; ``` 通过这种方式,我们就可以获取到在window.open()中传递的参数了。需要注意的是,如果新打开的窗口是一个从当前窗口打开的弹出窗口,则可以使用window.opener来获取父窗口的一些信息,例如父窗口的URL、窗口大小等等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值