且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测窗口垂直滚动条何时出现

更新时间:2023-11-09 12:17:22

Window.onresize 不起作用,因为窗口没有调整大小。

Window.onresize won't work, because the window isn't resizing.

body.onresize 将无效,因为调整大小仅适用于Windows和框架。

body.onresize won't work, as resize is implemented only for windows and frames.

此问题 处理同一问题。***回答者有一些有趣的想法,虽然不是简单的,或跨浏览器。

This question deals with the same issue. The top answerer has some interesting ideas, though none simple, or cross-browser.

我认为Rick Strahl基于Jquery的方法是你能得到的***的: 监控JavaScript中的Html元素CSS更改 浏览器的监视功能(如果可用)或计时器(如果不可用)。后者不是非常有利于资源,但似乎没有办法解决它。

I think this Jquery based approach by Rick Strahl is the best you can get: Monitoring Html Element CSS Changes in JavaScript it uses the browser's "watch" functions if available, or a timer if not. The latter is not very resource friendly but there seems to be no way around it.

一旦调整大小,如何告诉滚动条的好方法/ code>解决的问题是 这个问题 顺便说一句,以防您在提问时没有提到那个。

A good way how to tell the scrollbar once the resize thing is resolved is in this question by the way, just in case you aren't referring to that one in your question.