![]() |
1
uniquecolesmith OP 垃圾百度搜到的都是错误答案~~
|
![]() |
2
yangg 2015-07-09 21:22:07 +08:00 ![]() $(window).height();
如果是<! doctype html> 或者其它不是quicks mode 的dtd的话,用 document.documentElement.clientHeight |
![]() |
3
adjusted 2015-07-09 21:26:52 +08:00 ![]() window.innerHeight?
|
![]() |
4
uniquecolesmith OP |
![]() |
5
yangg 2015-07-09 21:32:00 +08:00 ![]() 。。。可视高度,
$(document).height(); document.body.clientHeight; |
![]() |
6
emric 2015-07-09 21:40:23 +08:00 ![]() document.documentElement.clientHeight
|
![]() |
7
emric 2015-07-09 21:49:43 +08:00 ![]() 刚才没细看上面的回复, 有滚动条或加载动态内容后有滚动条, 应该在 resize 和 onload 还有 AJAX 后, 重新获取.
|
![]() |
8
uniquecolesmith OP |
![]() |
9
learnshare 2015-07-09 22:11:30 +08:00 ![]() |
![]() |
10
emric 2015-07-09 22:23:15 +08:00 ![]() @uniquecolesmith 你可以试着写个 demo 让大家看看, 话说 x 的滚动条很少会用到吧.
|
![]() |
11
emric 2015-07-09 22:28:45 +08:00
还有我再纠正一下, 我上面的 7L 的回复应该是: "调整窗口有滚动条或者加载动态内容后有滚动条, 应该在 resize 和 onload 还有 AJAX 后, 重新获取. "
语死早, 没办法.. ʅ(´◔౪◔)ʃ |
![]() |
12
Biwood 2015-07-09 23:25:46 +08:00 ![]() 看了下楼主的回复,难道他说的不是 document.documentElement.offsetHeight 么?
|
![]() |
13
uglyer 2015-07-10 10:41:27 +08:00 ![]() 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 |