jquery兑现浮动面板 监听页面滚动和大小变化事件
jquery实现浮动面板 监听页面滚动和大小变化事件
(function showQQPanel(){ var _windowScrollTop=0; //滚动条距离顶端距离 var _windowWidth=jQuery(window).width(); //窗口宽度 jQuery(window).scroll(actionEvent).resize(actionEvent); //监听滚动条事件和窗口缩放事件 //响应事件 function actionEvent(){ _windowScrollTop = jQuery(window).scrollTop(); //获取当前滚动条高度 _windowWidth=jQuery(window).width();//获取当前窗口宽度 moveQQonline();//移动面板 } //移动面板 function moveQQonline(){ //.stop()首先将上一次的未完事件停止,否则IE下会出现慢速僵死状态,然后重新设置面板的位置。 $("#divQQbox").stop().animate({ right:5, top: _windowScrollTop+145 }, "normal"); } })();