开发者

Is there a way to measure the height of what's visible to the user in his website?

I want to measure the height of the visible content area (that means - the top side of it is located where I start to see the site's content and that it end开发者_如何学编程s where I have the windows or mac task panel) in Javascript somehow. It varies from browser to browser and whether I have other panels in the browser then it changes its size.

How can I get this data?


Here are a few useful Javascript (not jQuery) tools you can use to find this:

document.body.offsetWidth
document.body.offsetHeight

These find the Width and Height of the body element (so unless you've done something strange to the body element, then this should work).

You also have:

window.innerWidth
window.innerHeight

These would give you the width of the browser viewport, like antimatterfish said.


Do you mean $(window).height(); and $(window).width(); ? "window" measures the browser viewport...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜