1
uniquecolesmith OP 垃圾百度搜到的都是错误答案~~
|
2
yangg Jul 9, 2015 $(window).height();
如果是<! doctype html> 或者其它不是quicks mode 的dtd的话,用 document.documentElement.clientHeight |
3
adjusted Jul 9, 2015 window.innerHeight?
|
4
uniquecolesmith OP |
5
yangg Jul 9, 2015 。。。可视高度,
$(document).height(); document.body.clientHeight; |
6
emric Jul 9, 2015 document.documentElement.clientHeight
|
7
emric Jul 9, 2015 刚才没细看上面的回复, 有滚动条或加载动态内容后有滚动条, 应该在 resize 和 onload 还有 AJAX 后, 重新获取.
|
8
uniquecolesmith OP |
9
learnshare Jul 9, 2015 |
10
emric Jul 9, 2015 @uniquecolesmith 你可以试着写个 demo 让大家看看, 话说 x 的滚动条很少会用到吧.
|
11
emric Jul 9, 2015
还有我再纠正一下, 我上面的 7L 的回复应该是: "调整窗口有滚动条或者加载动态内容后有滚动条, 应该在 resize 和 onload 还有 AJAX 后, 重新获取. "
语死早, 没办法.. ʅ(´◔౪◔)ʃ |
12
Biwood Jul 9, 2015 看了下楼主的回复,难道他说的不是 document.documentElement.offsetHeight 么?
|
13
uglyer Jul 10, 2015 if (window.innerWidth)
winWidth = window.innerWidth; else if ((document.body) && (document.body.clientWidth)) winWidth = document.body.clientWidth; // 获取窗口高度 if (window.innerHeight) winHeight = window.innerHeight; else if ((document.body) && (document.body.clientHeight)) winHeight = document.body.clientHeight; // 通过深入 Document 内部对 body 进行检测,获取窗口大小 if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) { winHeight = document.documentElement.clientHeight; winWidth = document.documentElement.clientWidth; } 我用这段可以兼容绝大部分浏览器。 |
14
uniquecolesmith OP |