现在功能是要类似于QQ聊天那样的到达顶部触发加载之前的聊天内容
我在电脑端实现的js,但我需要两端都能实现
var system ={
win : false,
mac : false,
xll : false
};
//检测平台
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
if(system.win||system.mac||system.xll){
window.onload = function () {
function onMouseWheel(ev) {/*当鼠标滚轮事件发生时,执行一些操作*/
var url = window.location.href;
if(url.indexOf("chat/detail") != -1){
var ev = ev || window.event;
var scrollTop=$(window).scrollTop();
if(scrollTop == 0){
if(chat_page < chat_totalPages){
getChatList(++chat_page);
}else{
return;
}
}
if(ev.preventDefault){/*FF 和 Chrome*/
ev.preventDefault();// 阻止默认事件
}
return false;
}
}
addEvent(document.body,'mousewheel',onMouseWheel);
addEvent(document.body,'DOMMouseScroll',onMouseWheel);
}
function addEvent(obj,xEvent,fn) {
if(obj.attachEvent){
obj.attachEvent('on'+xEvent,fn);
}else{
obj.addEventListener(xEvent,fn,false);
}
}
}