Assume that a page contains a lot of data and cannot be displayed easily. if there is a player in it and you do not want the player to terminate when turning pages, this method can be used even though Ajax can be used, but with less data, this method is more advantageous. JS code is as follows:
The code is as follows:
// Maximum data volume
Var total = "100 ";
// Display Volume per page
Var pagesize = 10;
// Total number of pages
Var pagenum = Math. ceil (total/pagesize );
// Generate navigation
Function initpage (nowpage ){
Var pagenav = 'preview ';
For (I = 1; I <= pagenum; I ++ ){
Pagenav + = (I = nowpage )? ''+ I +'': ''+ I + '';
}
Pagenav + = 'next page ';
Document. getElementById ('Pages '). innerHTML = pagenav;
}
// Page flip
Function goToPage (page ){
Var start = (page-1) * pagesize;
Var max = page * pagesize;
For (vs = 0;
Var export bj = document. getElementById ('item _ '+ );
Obj. style. display = "none ";
}
If (max> total) max = total;
For (v = start; v
Var export bj = document. getElementById ('item _ '+ v );
Obj. style. display = "block ";
}
Initpage (page );
}
// Previous Page
Function up (nowpage ){
If (nowpage = 1) return false;
If (nowpage> 1) goToPage (nowpage-1 ));
}
// Next page
Function down (nowpage ){
If (nowpage = pagenum) return false;
If (nowpage
}
If the data is
.........
.........
...........
........
Then a navigation similar to this is displayed:
Previous Page 1 2 3 4 Next Page
Click the page number or the next page to switch to display.
The time is too short. so much is said. if you do not understand the code, leave a message.