获取浏览器宽度和高度,不包括工具栏和菜单大小
Get Browser Width and Height Excluding Toolbars and Menu Size
我需要一个Js/JQuery脚本,它返回我浏览器的可用宽度和高度,不包括菜单栏和工具栏大小,我使用一个脚本,但它似乎返回宽度/高度,包括工具栏等等。。。
下面是我用过的脚本。。
<script type="text/javascript" >
var winWidth = 0, winHeight = 0;
if (typeof (window.innerWidth) == 'number') {
//Non-IE
winWidth = window.innerWidth;
winHeight = window.innerHeight;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
//IE 6+ in 'standards compliant mode'
winWidth = document.documentElement.clientWidth;
winHeight = document.documentElement.clientHeight;
} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
//IE 4 compatible
winWidth = document.body.clientWidth;
winHeight = document.body.clientHeight;
}
</script>
有人知道这方面的线索吗?谢谢Meghana
使用jQuery,您可以获得以下内容:
$(window).height(); // returns height of browser viewport
$(document).height(); // returns height of HTML document
您的代码应该返回浏览器窗口的可用大小。在我的情况下,在1920x1200的显示器上,我得到1920x1106。我的任务栏有40像素高,所以剩下54像素作为窗口的标题栏。
try:
<input type='button' id='btn1' value='test'/>
$('#btn1').click(function(){
alert($(window).width());
});
请参阅http://jsfiddle.net/Pu2Ej/
相关文章:
- 删除CKEditor工具栏按钮,但不删除功能
- Sencha触摸:工具栏无法正常滚动
- NWJS(Node Webkit)使用左键单击打开任务栏菜单
- 使用网格ID隐藏剑道网格工具栏
- Dojo栏菜单在选定状态下堆叠
- 如何在IE中隐藏菜单栏,工具栏
- TinyMce 子菜单在使用fixed_toolbar_container和绝对位置时不粘附于工具栏
- Kendo UI网格单元格中的工具栏菜单,菜单是从哪个行单击的
- 获取浏览器宽度和高度,包括工具栏和菜单大小
- 获取浏览器宽度和高度,不包括工具栏和菜单大小
- 如何创建没有地址/菜单和工具栏的网页
- ext.js 6工具栏中的下拉菜单
- 如何使用jquery或javascript计算浏览器菜单栏,工具栏,导航栏,书签的高度
- TinyMCE自定义工具栏菜单项单击触发所有父项的单击事件
- 删除浏览器窗口工具栏和菜单栏没有窗口打开
- jquery菜单结合stumbleupon工具栏的子菜单定位出错
- 如何将“;所有“;项目进入搜索工具栏的选择菜单
- 将菜单项添加到CKEditor XPages中的默认工具栏
- jquery 中的浮动菜单工具栏
- 工具栏中的菜单 - ext-JS 4.