确定浏览器观看的实际大小 [英] Determine actual viewing size in browser

查看:208
本文介绍了确定浏览器观看的实际大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以确定当前浏览器窗口的实际视口大小。我试过:

I am trying to determine the actual viewPORT size of the current browser window. I've tried:


  • window.innerHeight / innerWidth

  • document.documentElement.clientHeight / clientWidth

  • document.body.clientHeight / clientWidth

所有返回完整的页面大小,而不是观赏区。

All return the full page size and NOT the viewing area.

我试图来最终达到迫使一个弹出菜单出现在屏幕上(在视口中)。现在,当显示,它可能会显示滚动下方和用户并不高兴。我知道X,他们点击过其中y。我只需要比较,为可视面积(以弹出窗口的大小)的大小,看它是否会去屏幕外。

What I'm trying to ultimately achieve is forcing a popup menu to appear on screen (in the viewport). Right now when it is shown, it might show below the scroll and the users are not happy with that. I know the x,y of where they've clicked. I just need to compare that to the size of the viewing area (with the size of the popup) to see if it will go offscreen.

应该指出的是,页面显示一个IFRAME,所以如果我需要去上一级来得到正确的值,我能做到这一点。

It should be noted that the page is showing in an IFRAME, so if I need to go up one level to get the correct value, I can do that.

推荐答案

显然通过转到父文档,我能得到正确的值。

Apparently by going to the parent document, I was able to get the correct value.

谢谢!

这篇关于确定浏览器观看的实际大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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