新闻内页-JS分页_JavaScript

WBOY
Lepaskan: 2016-05-16 19:29:28
asal
1075 orang telah melayarinya
'//判断内容里是不是包含这个分页标签
if instr(cinfo,"[NextPage]")>0 then
flag=1
else
flag=0
end if

'//设置参数


'//JS文件包函


'//文本显示





'//下面为JS文本处理函数

function DealJsText(Str)
if not isnull(Str) then
Dim re,po,ii
Str = Replace(Str, CHR(9), " ")
Str = Replace(Str, CHR(39), "'")
Str = Replace(Str, CHR(13), "")
Str = Replace(Str, CHR(10) & CHR(13), "

")
Str = Replace(Str, CHR(10), "")
Str = Replace(Str, "‘", "'")
Str = Replace(Str, "'", "'")
Str = Replace(Str, "\", "\\")
Str = Replace(Str, CHR(32), " ")
Str = Replace(Str, CHR(34), "\""")
Str = Replace(Str, CHR(39), "'")
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
po=0
ii=0
re.Pattern="(javascript)"
Str=re.Replace(Str,"javascript")
re.Pattern="(jscript:)"
Str=re.Replace(Str,"jscript:")
re.Pattern="(js:)"
Str=re.Replace(Str,"js:")
re.Pattern="()"
Str=re.Replace(Str,"")
re.Pattern="(<script>Str=re.Replace(Str,"<script")<BR>DealJsText = Str<BR>End if<BR>end Function<br><br>'//下面为JS文件 CutArticle.js<BR>var currentSet,CutFlag,TotalByte,PageCount,key,tempText,tempPage;<BR>key="";<BR>currentSet=0;<BR>TotalByte=Text.length;<BR>if (flag==1)<BR>{<BR>PageCount=Math.round(TotalByte/PageSize);<BR>if(parseFloat("0."+TotalByte%PageSize)>0){<BR>if(parseFloat("0."+TotalByte%PageSize)<0.5){<BR>PageCount=PageCount+1;<BR>}<BR>}<BR>var PageNum=new Array(PageCount+1);<BR>var PageTitle=new Array(PageCount+1);<BR>PageNum[0]=0;<BR>PageTitle[0]="";<br><br>var sDrv1,sDrv2,sDrv3,sDrv4,sFlag;<BR>var sDrvL,sTemL;<BR>var sTem1,sTem2,k;<BR>sFlag=0;<br><br>for(j=1;j<PageCount+1;j++){<BR>PageNum[j]=PageNum[j-1]+PageSize;<BR>PageTitle[j]="";<BR>//alert(j);<BR>sDrv1="<br>";<BR>sDrv2="<BR>";<BR>sDrv3="<Br>";<BR>sDrv4="<bR>";<BR>sDrvL=sDrv1.length;<BR>for(k=PageNum[j];k<=TotalByte;k++){<BR>sTem1=Text.substring(PageNum[j]-sDrvL,k);<BR>sTemL=sTem1.length;<BR>sTem2=sTem1.substring(sTemL-sDrvL,sTemL)<BR>if (sTem2==sDrv1 || sTem2==sDrv2 || sTem2==sDrv3 || sTem2==sDrv4)<BR>{<BR>sFlag=sFlag+1;<BR>PageNum[j]=k;<BR>break;<BR>}<BR>}<BR>if (PageNum[j]>TotalByte)<BR>{<BR>break;<BR>}<BR>}<BR>if (j<PageCount)<BR>{<BR>PageNum.length=j;<BR>PageCount=j<BR>}<BR>if (PageCount>1&&sFlag>1&&PageCount<sFlag)<BR>{<BR>PageCount=sFlag+1;<BR>}<BR>}<BR>else{<BR>//手动分页<BR>var j,sFlag,PageCount,sText;<BR>var sTitleFlag;<BR>var PageNum=new Array();<BR>var PageTitle=new Array();<BR>PageSize=0;<BR>j=1;<BR>PageNum[0]=-10;<BR>PageTitle[0]=""; <BR>sFlag=0;<BR>sText=Text;<BR>do<BR>{<BR>sText=Text.substring(PageNum[j-1]+10,TotalByte);<BR>sFlag=sText.indexOf("[NextPage");<BR>if (sText.substring(sFlag+9,sFlag+10)=="=")<BR>{<BR>sTitleFlag=sText.indexOf("]",sFlag);<BR>PageTitle[j]=sText.substring(sFlag+10,sTitleFlag);<BR>}<BR>else{<BR>PageTitle[j]="";<BR>}<BR>if (sFlag>0)<BR>{<BR>PageNum[j]=sFlag+PageNum[j-1]+10;<BR>}<BR>else{<BR>PageNum[j]=TotalByte;<BR>}<BR>j+=1;<BR>}<BR>while (PageNum[j-1]<TotalByte);<BR>PageCount=j-1;<BR>}<br><br>function CovertCRLFToBR(s) <BR>{ <BR>var i; <BR>var s2 = s; <br><br>while(s2.indexOf("[NextPage]")>0) <BR>{ <BR>i = s2.indexOf("[NextPage]"); <BR>s2 = s2.substring(0, i) + "" + s2.substring(i + 10, s2.length); <BR>} <BR>return s2; <BR>} <BR>function text_pagination(Page){<BR>var Output,Byte;<BR>if(Page==null){Page=1;} <BR>Output="";<BR>Output=Output+"<table width=100% height=30 border=0 align=center cellpadding=0 cellspacing=0>";<BR>Output=Output+"<tr>";<BR>Output=Output+"<td height=1 background=Images/DotLine.gif>";<BR>Output=Output+"";<BR>//头部功能导航条<BR>Output=Output+"<tr>";<BR>//正文查找<BR>Output=Output+"<td align=left width='40%'> "; <BR>Output=Output+"<input type=hidden name=keys class=iptA onchange='key=this.value' size=12> <input type=hidden class=btnA name=search value='查找正文' onclick='searchkey();' style='width:60'>";<BR>Output=Output+"";<BR>Output=Output+"<td align=right>";<BR>//页码显示方式一<BR>//第x页:分页标题<BR>if (Page==0 || PageCount==0){<BR>Output=Output+"当前是:<font color=red>全文显示" ; <BR>}<BR>else{<BR>if(TotalByte>PageSize){Byte=PageNum[Page]-PageNum[Page-1]}else{Byte=TotalByte};<BR>Output=Output+"第 <font color=red>"+Page+" 页";<BR>if (PageTitle[Page]!="")<BR>{<BR>Output=Output+":<font color=800000>"+PageTitle[Page]+"";<BR>}<BR>}<BR>//显示方式二<BR>//下拉菜单选择<BR>//if (PageCount>0)<BR>//{<BR>// Output=Output+PageNav(2,Page);<BR>// Output=Output+" ";<BR>//}<BR>//显示方式三<BR>//页码选择列表<BR>//Output=Output+"<td align=right bgcolor=#f0faff>";<BR>//Output=Output+PageNav(0,Page);<BR>//Output=Output+"";<BR>Output=Output+"";<BR>Output=Output+"<tr>";<BR>Output=Output+"<td height=1 background=Images/DotLine.gif>";<BR>Output=Output+"";<BR>Output=Output+"";<BR>//显示正文<BR>if(Page==0) {<BR>//不分页<BR>tempText=CovertCRLFToBR(Text);<BR>}<BR>else{<BR>//分页<BR>if (flag==1)<BR>//自动分页<BR>{<BR>tempText=Text.substring(PageNum[Page-1],PageNum[Page]); <BR>}<BR>else{<BR>//手动分页<BR>if (PageTitle[Page-1].length==0)<BR>{<BR>tempText=Text.substring(PageNum[Page-1]+10,PageNum[Page]);<BR>}<BR>else{<BR>tempText=Text.substring(PageNum[Page-1]+11+PageTitle[Page-1].length,PageNum[Page]);<BR>}<BR>}<BR>}<BR>Output=Output+"<div id=world>";<BR>Output=Output+tempText;<BR>Output=Output+"";<BR>Output=Output+"<br>";<BR>Output=Output+"<div align=center>";<BR>Output=Output+PageNav(1,Page);<BR>Output=Output+"";<br><br>article.innerHTML = Output;<BR>document.location.href='#';<BR>eval(document.all.keys).value=key;<BR>if (key!=""){searchkey();}<BR>}<br><br>function searchkey(){<BR>//正文查找函数<BR>h="<font class=keyworld>";<BR>f="";<BR>keyset=new Array();<BR>key=document.all.keys.value;<BR>if (key==""){<BR>alert("请输入关键字!");<BR>return;<BR>}<BR>else{<BR>keyset[0]=tempText.indexOf(key,0);<br><br>if (keyset[0]<0){<BR>return;<BR>}else<BR>temp=tempText.substring(0,keyset[0]);<BR>temp=temp+h+key+f;<BR>temp2=tempText.substring(keyset[0]+key.length,tempText.length);<BR>for (i=1;i<tempText.length;i++) {<BR>keyset[i]=tempText.indexOf(key,keyset[i-1]+key.length);<BR>if(keyset[i]<0){<BR>temp=temp+tempText.substring(keyset[i-1]+key.length,tempText.length);<BR>break;<BR>}else{<BR>temp=temp+tempText.substring(keyset[i-1]+key.length,keyset[i])+h+key+f;<BR>}<BR>}<BR>world.innerHTML = temp;<BR>}<BR>}<BR>function PageNav(ShowStyle,Page){<BR>//分页码显示函数<BR>//参数为调用样式,0=简单样式,1=标准样式<BR>var temp="";<BR>if (ShowStyle==0)<BR>//简单样式<BR>{<BR>tempPage=Page;<BR>if(TotalByte>PageSize){ <BR>if (Page-4<=1){<BR>temp=temp+"<font face=webdings color=#999999>9";<BR>if (Page<=1){temp=temp+"<font face=webdings color=#999999>7";}else{temp=temp+"<a href=javascript:text_pagination("+(Page-1)+")><font face=webdings>7";}<BR>if (PageCount>10){<BR>for(i=1;i<8;i++){<BR>if (i==Page){<BR>temp=temp+"<font color=red>"+i+" ";<BR>}else{<BR>temp=temp+"<a href=javascript:text_pagination("+i+") >"+i+""+" ";<BR>}<BR>}<BR>temp=temp+" ...";<BR>}<BR>else{<BR>for(i=1;i<PageCount+1;i++){<BR>if (i==Page){<BR>temp=temp+"<font color=red>"+i+" ";<BR>}<BR>else{<BR>temp=temp+"<a href=javascript:text_pagination("+i+") >"+i+""+" ";<BR>}<BR>}<BR>}<BR>if (Page==PageCount){temp=temp+"<font face=webdings color=#999999>8";}else{temp=temp+"<a href=javascript:text_pagination("+(Page+1)+")><font face=webdings>8";}<BR>if(PageCount<10){temp=temp+"<font face=webdings color=#999999>:";}else{temp=temp+"<a href=javascript:text_pagination("+PageCount+")><font face=webdings>:";}<BR>}<BR>else if(Page+4<=PageCount){<BR>temp=temp+"<a href=javascript:text_pagination(1)><font face=webdings>9";<BR>temp=temp+"<a href=javascript:text_pagination("+(Page-1)+")><font face=webdings>7";<BR>if (PageCount>10){<BR>temp=temp+"..";<BR>for(i=Page-4;i<Page+4;i++){<BR>if (i==Page){<BR>temp=temp+"<font color=red>"+i+" ";<BR>}<BR>else{<BR>temp=temp+"<a href=javascript:text_pagination("+i+") >"+i+""+" ";<BR>}<BR>}<BR>temp=temp+" ..";<BR>}<BR>else{<BR>for(i=1;i<PageCount+1;i++){<BR>if (i==Page){<BR>temp=temp+"<font color=red>"+i+" ";<BR>}<BR>else{<BR>temp=temp+"<a href=javascript:text_pagination("+i+") >"+i+""+" ";<BR>}<BR>}<BR>}<br><br>if (Page==PageCount){temp=temp+"<font face=webdings color=#999999>8";}else{temp=temp+"<a href=javascript:text_pagination("+(Page+1)+")><font face=webdings>8";}<BR>temp=temp+"<a href=javascript:text_pagination("+PageCount+")><font face=webdings>:";<BR>}<BR>else{<BR>temp=temp+"<a href=javascript:text_pagination(1)><font face=webdings>9";<BR>temp=temp+"<a href=javascript:text_pagination("+(Page-1)+")><font face=webdings>7";<BR>temp=temp+".."<BR>for(i=Page-2;i<PageCount+1;i++){<BR>if (i==Page){<BR>temp=temp+"<font color=red>"+i+" ";<BR>}<BR>else{<BR>temp=temp+"<a href=javascript:text_pagination("+i+") >"+i+""+" ";<BR>}<BR>}<BR>if (Page==PageCount){temp=temp+"<font face=webdings color=#999999>8";}else{temp=temp+"<a href=javascript:text_pagination("+(Page+1)+")><font face=webdings>8";}<BR>temp=temp+"<font face=webdings color=#999999>:";<BR>}<BR>}<BR>else{<BR>temp=temp+"<font color=red>1 ";<BR>}<BR>temp=temp+" <a href=javascript:text_pagination(0)>显示全部"<BR>}<BR>else if (ShowStyle==1)<BR>//标准样式<BR>{<BR>if(TotalByte>PageSize){if(Page!=0){if(Page!=1){temp=temp+"<a href='#top' onclick=javascript:text_pagination("+(Page-1)+")><font color=3366cc>[上一页] ";}}}<BR>for (i=1;i<PageCount+1 ;i++ )<BR>{<BR>if (Page==i)<BR>{<BR>temp=temp+"<font color=800000>["+i+"] ";<BR>}<BR>else{<BR>temp=temp+"<a href='#top' onclick=javascript:text_pagination("+i+")><font color=3366cc>["+i+"] ";<BR>}<BR>}<BR>temp=temp+"<a name='foot'>";<BR>if(TotalByte>PageSize){if(Page!=0){if(Page!=PageCount){temp=temp+"<a href='#top' onclick=javascript:text_pagination("+(Page+1)+")><font color=3366cc>[下一页]";}}}<BR>temp=temp+" <a href=javascript:text_pagination(0)><font color=3366cc>显示全部"<BR>}<BR>else if (ShowStyle==2)<BR>//下拉菜单样式<BR>{<BR>temp=temp+'<select onchange="text_pagination(this.value)">'<BR>for (i=1;i<PageCount+1 ;i++ )<BR>{<BR>if (Page==i)<BR>{<BR>temp=temp+"<option value='"+i+"' selected style='color:red'>第 "+i+" 页"<br><br>}<BR>else{<BR>temp=temp+"<option value='"+i+"'>第 "+i+" 页";<BR>}<BR>if (PageTitle[i].length!=0)<BR>{<BR>temp=temp+':'+PageTitle[i];<BR>}<BR>temp=temp+"";<BR>}<BR>temp=temp+"";<BR>}<br><br>return (temp);<BR>}</script>

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!