setTimeout(function() { var $report = $("div"); //获取对应report的div元素 var $scroll = $report.find(".reportContent"); //获取对应report的div元素的滚动块元素,冻结为#frozen-center,未冻结且未安装自定义滚动条插件为.reportContent,未冻结且安装了自定义滚动条插件为.scrollDiv var flag = window.flag0; //设置全局变量flag,每个报表块需保证各不相同 $report.find("#frozen-center").css('overflow-x', 'hidden'); $report.find("#frozen-center").css('overflow-y', 'hidden'); $report.find("#frozen-north").css('overflow-x', 'hidden'); $report.find("#frozen-north").css('overflow-y', 'hidden'); //冻结情况下隐藏滚动条 $report.find(".reportContent").css('overflow-y', 'hidden'); $report.find(".reportContent").css('overflow-x', 'hidden'); //非冻结情况下隐藏滚动条 flag = true; //定义全局参数flag,用来控制滚动的暂停和继续 $scroll.mouseover(function() { flag = false; }) //鼠标悬浮,滚动停止 $scroll.mouseleave(function() { flag = true; }) //鼠标离开,继续滚动 var old = -1; setInterval(function() { if (flag) { currentpos = $scroll.scrollTop; //获取距顶部距离 if (currentpos == old) { $scroll.scrollTop = 0; //若已到达底部,则重置 } else { old = currentpos; $scroll.scrollTop = currentpos + 1.5; //若未到达底部,则向下移动1.5像素 } } },24); //以24ms的频率执行}, 500);