网站真分页js代码该怎么写?

发布时间:2020-07-24 16:42:23 作者:haoning747
来源:网络 阅读:1040

真分页这个词对程序猿们来说,并不是一个陌生的词汇,但是如果你是初次学习真分页,或许还是得花点时间小小研究下,下面是之前去转盘网(喜欢的可以看看,也可以进入引擎模式)的真分页js部分代码,html部分的我就不写了,稍微处理下代码就可以使用的,你也可以根据需要灵活变动,千万不要懒惰哦,废话不说了,直接上代码:

function get_param(param){ //这个函数是用来获取url的参数的 

var query = location.search.substring(1).split('&'); 
for(var i=0;i<query.length;i++){ 
var kv = query[i].split('='); 
if(kv[0] == param){ 
return kv[1]; 
} 
} 
return null; 
} 

$("#page_down").unbind().bind('click',function(){ //向下翻页 

temp=get_param("currentPage"); 
if(temp==null || isNaN(temp)){ //非数字或者无页码 
toPage=1; 
} 
else{ 
toPage=parseInt(temp)+1; 
} 
ifnull=$("#ifnull").attr("value"); 
if(ifnull.length<3){ 
toPage=1; 
} 
url="${pageContext.request.contextPath }/funnyPic.do?currentPage="+toPage; 
window.location.replace(url); 
}); 

$("#home").unbind().bind('click',function(){//回到首页 
url="${pageContext.request.contextPath }/funnyPic.do?currentPage=1"; 
window.location.replace(url); 
}); 

$("#page_up").unbind().bind('click',function(){ //向上翻页 
temp=get_param("currentPage"); 
if(temp==null || isNaN(temp)){ //非数字或者无页码 
toPage=1; 
} 
else{ 
toPage=parseInt(temp)-1; 
} 
if(toPage<1){ 
showMessage("亲~第一页了,真不知道往哪走了"); 
return; 
} 
ifnull=$("#ifnull").attr("value"); 
if(ifnull.length<3){ 
toPage=1; 
} 
url="${pageContext.request.contextPath }/index.do?currentPage="+toPage; 
window.location.replace(url); 
}); 

$(".turnPage").unbind().bind('click',function(){//翻页部分的代码 
toPage=parseInt($(this).text()+""); 
ifnull=$("#ifnull").attr("value"); 
if(ifnull.length<3){ 
toPage=1; 
} 
url="${pageContext.request.contextPath }/funnyPic.do?currentPage="+toPage; 
window.location.replace(url); 
});


推荐阅读:
  1. cdn属于一种技术吗
  2. jquery 输入框查找关键字并提亮颜色的实例代码

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

技术 互联网

上一篇:Postfix,dovecot邮件系统

下一篇:本地代码上传到Github

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》