请问下,同段的js为什么在pc端正常,移动端就不行了?
请问下,同段的js为什么在pc端正常,移动端就不行了?
html调用代码:
<div id="pgbtn" class="pgbtn_page">
<a class="page_a" href="javascript:;" rel="forum.php?order={$_GET['order']}&page=$ntpage" curpage="{$_G['page']}" id="autopbn" totalpage="{$fynum}" picstyle="$_G[forum][picstyle]" forumdefstyle="$_G[cookie][forumdefstyle]">点击加载更多</a>
<script type="text/javascript" src="{$_G[style][styleimgdir]}/js/exauto_ajax_page.js?{VERHASH}"></script>
</div>
js文件代码:
(function() {
var autopbn = $('autopbn');
var nextpageurl = autopbn.getAttribute('rel').valueOf();
var curpage = parseInt(autopbn.getAttribute('curpage').valueOf());
var totalpage = parseInt(autopbn.getAttribute('totalpage').valueOf());
var picstyle = parseInt(autopbn.getAttribute('picstyle').valueOf());
var forumdefstyle = parseInt(autopbn.getAttribute('forumdefstyle').valueOf());
picstyle = picstyle && !forumdefstyle;
var autopagenum = 0;
var maxpage = (curpage + autopagenum) > totalpage ? totalpage : (curpage + autopagenum);
var loadstatus = 0;
autopbn.onclick = function() {
var oldloadstatus = loadstatus;
loadstatus = 2;
autopbn.innerHTML = '正在加载, 请稍后...';
getnextpagecontent();
loadstatus = oldloadstatus;
};
if(autopagenum > 0) {
window.onscroll = function () {
var curtop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
if(curtop + document.documentElement.clientHeight + 500 >= document.documentElement.scrollHeight && !loadstatus) {
loadstatus = 1;
autopbn.innerHTML = '正在加载, 请稍后...';
setTimeout(getnextpagecontent, 1000);
}
};
}
function getnextpagecontent() {
if(curpage + 1 > totalpage) {
window.onscroll = null;
autopbn.innerHTML = '没有更多了...';
return;
}
if(loadstatus != 2 && curpage + 1 > maxpage) {
autopbn.innerHTML = '点击加载更多';
if(curpage + 1 > maxpage) {
window.onscroll = null;
}
return;
}
curpage++;
var url = nextpageurl + '&t=' + parseInt((+new Date()/1000)/(Math.random()*1000));
var x = new Ajax('HTML');
x.get(url, function (s) {
s = s.replace(/\n|\r/g, '');
if(s.indexOf("id=\"autopbn\"") == -1) {
$("autopbn").innerHTML = '没有更多了...';
window.onscroll = null;
}
if(!picstyle) {
var tableobj = $('thread-list');
var nexts = s.match(/\<article id="normalthread_(\d+)" class="topic-visited"\>(.+?)\<\/article>/g);
for(i in nexts) {
if(i == 'index' || i == 'lastIndex') {
continue;
}
var insertid = nexts[i].match(/<article id="normalthread_(\d+)" class="topic-visited"\>/);
if(!$('normalthread_' + insertid[1])) {
var newbody = document.createElement('article');
tableobj.appendChild(newbody);
var div = document.createElement('div');
div.innerHTML = '<div>' + nexts[i] + '</div>';
tableobj.replaceChild(div.childNodes[0].childNodes[0], tableobj.lastChild);
}
}
} else {
var nexts = s.match(/\<li style="width:\d+px;" id="picstylethread_(\d+)"\>(.+?)\<\/li\>/g);
for(i in nexts) {
var insertid = nexts[i].match(/id="picstylethread_(\d+)"\>/);
if(!$('picstylethread_' + insertid[1])) {
$('threadlist_picstyle').innerHTML += nexts[i];
}
}
}
var pageinfo = s.match(/\<div id="fd_page_bottom" class="panel-footer clearfix"\>(.+?)\<\/div\>/);
nextpageurl = nextpageurl.replace(/&page=\d+/, '&page=' + (curpage + 1));
$('fd_page_bottom').innerHTML = pageinfo[1];
if(curpage + 1 > totalpage) {
autopbn.innerHTML = '没有更多了...';
} else {
autopbn.innerHTML = '点击加载更多';
}
loadstatus = 0;
});
}
})();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要补充具体环境:
PC端的浏览器、版本
移动端是否是微信自带浏览器、浏览器、版本
而且你也没说具体怎么不行了,怎么讲。