您现在的位置:主页 > 发展 >

jquery判断是否出现滚动条的方法

标签: 日期:2020-12-14 15:24来源:未知作者:admin
jquery判断是否出现滚动条的方法:1、通过if ($(window).height() $(document).height() ){}方法判断可视区域是否超过实际高度;2、通过if语句判断屏幕可用工作区高度即可。 本教程操作环境:wi

  jquery判断是否出现滚动条的方法:1、通过“if ($(window).height() < $(document).height() ){}”方法判断可视区域是否超过实际高度;2、通过if语句判断屏幕可用工作区高度即可。

  本教程操作环境:windows7系统、jquery1.10.0版本,该方法适用于所有品牌电脑。

  :《jquery视频教程》

  jquery判断是否出现滚动条

  一、判断可视区域是否超过实际高度,超过一定存在

  if ($(window).height() < $(document).height() ) { alert('出现滚动条') }

  使用原生JavaScript的写法

  if (document.documentElement.clientHeight < document.documentElement.offsetHeight){ alert('出现滚动条') }

  二、屏幕可用工作区高度>=网页可见区域

  if (window.screen.availHeight >= document.body.clientHeight) { alert("页面无滚动条") } else { alert("页面有滚动条") }

  注:

  ● $(window).height() // 浏览器窗口可视区域高度

  document.documentElement.clientHeight

  ● $(document).height() // 浏览器窗口文档的高度

  document.documentElement.offsetHeight

  ● window.screen.availHeight // 屏幕可用工作区高度

  ● document.body.clientHeight // 网页可见区域

顶一下
(0)
0%
踩一下
(0)
0%
相关文章
共有人强势围观,期待你的评论!评论区
小提示: 本站的评论不需要审核,即发即显,有什么话你就尽管说吧,但不要过激哦,以免遭跨省处理!

验证码:点击我更换图片 匿名评论
最新评论