为什么滚动输出的值是未定义的?我正在使用chrome进行扩展。
var scroll = document.body.scrollTop;
console.log(scroll);
答案 0 :(得分:0)
W3C文档位于:
Open Source Load Testing Tools: Which One Should You Use?
来自文档:
var body = document.body; // Safari
var html = document.documentElement;
// Chrome, Firefox, IE and Opera places the overflow at
// the <html> level, unless else is specified. Therefore,
// we use the documentElement property for these browsers
body.scrollLeft += 30;
body.scrollTop += 10;
html.scrollLeft += 30;
html.scrollTop += 10;