真分頁這個詞對程序猿們來講,並非一個陌生的詞彙,可是若是你是初次學習真分頁,或許仍是得花點時間小小研究下,下面是以前去轉盤網(喜歡的能夠看看,也能夠進入引擎模式)的真分頁js部分代碼,html部分的我就不寫了,稍微處理下代碼就能夠使用的,你也能夠根據須要靈活變更,千萬不要懶惰哦,廢話不說了,直接上代碼:html
function get_param(param){ //這個函數是用來獲取url的參數的jsp
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);
});this
$("#home").unbind().bind('click',function(){//回到首頁
url="${pageContext.request.contextPath }/funnyPic.do?currentPage=1";
window.location.replace(url);
});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);
});spa
$(".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);
});orm