js创建分页脚本
来源:互联网 发布:dnftgp角色数据不更新 编辑:程序博客网 时间:2024/05/16 23:02
//创建分页脚本 //_nPageCount 总页数 _nCurrIndex 当前页 _sPageName页面名 _sPageExt 页面后缀 function createPageHTML(_nPageCount, _nCurrIndex, _sPageName, _sPageExt){if(_nPageCount == null || _nPageCount<=1){return;}var nCurrIndex = _nCurrIndex || 1;//输出分页if(nCurrIndex == 1){// 1 输出首页和上一页document.write("<a class='toEnd' style='text-decoration:none'>首页</a><a class='toEnd prePage' style='text-decoration:none'>上一页</a><a class='num on' style='text-decoration:none'>1</a>");}else{//1.2 当前页不是首页var nPreIndex = nCurrIndex - 1;document.write("<a href=\""+_sPageName+"."+_sPageExt+"\">首页</a>");document.write("<a class='prePage' href=\"" + _sPageName + "."+_sPageExt+"?currentPage="+nPreIndex+"\">上一页</a>");document.write("<a class='num' href=\""+_sPageName+"."+_sPageExt+"?currentPage=1\">1</a>");}// 2 输出中间分页for(var i=2; i<=_nPageCount; i++){if(nCurrIndex == i)document.write("<a class='num on'>"+i + "</a>");elsedocument.write("<a href=\""+_sPageName + "."+_sPageExt+"?currentPage="+i+"\">"+i+"</a>");}// 3 输出下一页和尾页// 3.1 当前页是尾页if(nCurrIndex == _nPageCount){document.write("<a class='toEnd nextPage' style='text-decoration:none'>下一页</a><a class='toEnd' style='text-decoration:none'>尾页</a>");}// 3.2 当前页不是尾页else{var nNextIndex = nCurrIndex + 1;document.write("<a class='nextPage' href=\""+_sPageName + "."+_sPageExt+"?currentPage="+nNextIndex+"\">下一页</a>");document.write("<a href=\""+_sPageName+ "."+_sPageExt+"?currentPage="+_nPageCount+"\">尾页</a>");}}
在jsp页面需要添加分页的地方添加如下的代码:
<div class="pageNav clearfix"><SCRIPT LANGUAGE="JavaScript">createPageHTML(${totalPage}, ${currentPage}, "to_anns", "html");</SCRIPT></div>添加css
.pageNav {text-align: center;margin-top: 27px;}.pageNav a.toEnd {color: #999;}.pageNav .prePage {margin-right: 23px;}element.style {text-decoration: none;}.pageNav a.on {color: #E05717;font-weight: bold;}.pageNav a {padding: 6px;}.pageNav a.num {color: #666;}.pageNav .nextPage {margin-left: 23px;}
解释下createPageHTML这个方法的四个参数
①_nPageCount:总页数,从action中传过来
②_nCurrIndex:当前的页码
③_sPageName:action的名字
④_sPageExt:action的后缀
0 0
- js创建分页脚本
- 分页7种JS脚本分页代码
- 7种JS脚本分页代码
- 7种JS脚本分页代码
- 7种js脚本分页代码
- 7种JS脚本分页代码
- js分页脚本代码入门实例
- HTML纯Js分页,带分页脚本和数据例子
- riot.js学习【七】脚本创建标签
- 脚本分页
- 分页脚本
- 记录一个自己常用的JS 分页 + 渲染脚本
- 转:7种JS脚本分页代码 showPages v1.0
- 7种JS脚本分页代码 showPages v1.0
- Ajax中主页加载分页面后,分页面js脚本不执行的解决办法
- jquery.pagination.js创建一个漂亮的分页条
- 前台JS脚本出现“Automation服务器不能创建对象“错
- js脚本报错:Automation 服务器不能创建对象
- Sequoiadb 测试体验系列之五 – Java 开发2
- 百度编辑器ueditor常用设置函数大全
- mysql grant 用户权限总结
- 常见的三种排序算法(堆排、快排、归并排序)的比较总结
- set /p= 详解
- js创建分页脚本
- aruba AP密码忘记恢复出厂设定
- 第二题 我在百度搜到的 你看下对不对 常
- iOS UIGestureRecognizer的使用
- Ubuntu命令集
- linux 下安装postgesql
- C8051F410在线调试接口说明
- 多步 OLE DB 操作产生错误
- 选数问题