onscroll属性
元素上scroll事件的事件处理程序。
onscroll属性语法element.onscroll = functionReference
参数
functionReference是对element滚动时执行的函数的引用。
onscroll属性示例
#container {
position: absolute;
height: auto;
top: 0;
bottom: 0;
width: auto;
left: 0;
right: 0;
overflow: auto;
}
#foo {
height:1000px;
width:1000px;
background-color: #777;
display: block;
}
document.getElementById('container').onscroll = function() {
console.log("scrolling");
};
笔记
当用户滚动元素的内容时, 将引发滚动事件。Element.onscroll相当于element.addEventListener("scroll" ... )。
规范规范状态注释文档对象模型 (DOM) 级别3事件规范
该规范中'onscroll'的定义。过时的初始定义
浏览器兼容性
我们正在将兼容性数据转换为机器可读的JSON格式。电脑端特征ChromeEdgeFirefox(Gecko)Internet ExplorerOperaSafari(WebKit)
基本支持支持支持????移动端
特征AndroidAndroid WebviewChrome for AndroidEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari Mobile
基本支持?支持支持支持?????