获取包括滚动条的浏览器窗口宽度 [英] Get browser window width including scrollbar

查看:209
本文介绍了获取包括滚动条的浏览器窗口宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 $(window).width(); 获取浏览器窗口宽度。在IE 10上,它确实返回完整的浏览器宽度,包括滚动条。但是,在Firefox和Chrome浏览器中,两者都会返回没有滚动条的值。



如何将浏览器宽度与滚动条一起使用?因为我需要检测到的宽度与CSS完全相同。

谢谢。

解决方案

div>

这将得到完整的窗口宽度:

$ p $ window.outerWidth

注意: jQuery的outerWidth()在$(window)无效

I tried to get browser window width with $(window).width();. On IE 10, it does return the full browser width, include the scroll bar. However, on Firefox and Chrome, both return the value without the scroll bar.

How can I get the browser width include with the scroll bar together? Because I need the detected width to be exactly same as CSS.

Thanks.

解决方案

This will get the full Window's width:

 window.outerWidth

NOTE: jQuery's outerWidth() doesn’t work on $(window)

这篇关于获取包括滚动条的浏览器窗口宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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