在JavaScript中确定浏览器窗口的位置? [英] Determining position of the browser window in JavaScript?

查看:124
本文介绍了在JavaScript中确定浏览器窗口的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于各种愚蠢的原因,我希望能够在屏幕上检测浏览器窗口的矩形。标题栏和所有。

For various silly reasons, I'd like to be able to detect the rectangle of the browser window on screen. Title bar and all.

这是可能的,还是JavaScript仅限于其页面的视口?

Is this possible, or is JavaScript limited to the view port of its page?

编辑:我可能一直不清楚,但是查看端口是页面中窗口中可见的部分。这可能不是浏览器常用的术语,但它在图形中很常见。

I may have been unclear, but view port is the portion of the page that's visible in the window. This may not be a term commonly used with browsers, but it's common in graphics.

推荐答案

对于符合标准的浏览器:

For standards compliant browsers:

X - window.screenX

Y - window.screenY

X - window.screenX
Y - window.screenY

对于IE:

X - window.screenLeft

Y - window.screenTop

X - window.screenLeft
Y - window.screenTop

请记住,实施方式各不相同。注意多显示器设置......

Keep in mind, implementations vary. Beware of multi-monitor setups...

这篇关于在JavaScript中确定浏览器窗口的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆