编程里一个很简单的问题!! 10
在前台显示文章内容的时候,要是文章的字太多了!!怎么给文章分页!!http://www.china.com.cn/policy/txt/2010-09/06/conten...
在前台显示文章内容的时候,要是文章的字太多了!! 怎么给文章分页!!
http://www.china.com.cn/policy/txt/2010-09/06/content_20867673.htm
大家看这个链接!! 它的文章就是跟内容分页了!!
请各位帮帮忙!! 追加分的!!
我用的是php!!!! 展开
http://www.china.com.cn/policy/txt/2010-09/06/content_20867673.htm
大家看这个链接!! 它的文章就是跟内容分页了!!
请各位帮帮忙!! 追加分的!!
我用的是php!!!! 展开
1个回答
展开全部
//手动分页
if (PageTitle[Page-1].length==0)
{
tempText=Text.substring(PageNum[Page-1]+10,PageNum[Page]);
}
else{
tempText=Text.substring(PageNum[Page-1]+11+PageTitle[Page-1].length,PageNum[Page]);
}
}
}
Output=Output+ " <div id=world> ";
Output=Output+tempText;
Output=Output+ " </div> ";
Output=Output+ " <br> ";
Output=Output+ " <div align=center> ";
Output=Output+PageNav(1,Page);
Output=Output+ " </div> ";
article.innerHTML = Output;
document.location.href= '# ';
eval(document.all.keys).value=key;
if (key!= " "){searchkey();}
}
function searchkey(){
//正文查找函数
h= " <font class=keyworld> ";
f= " </font> ";
keyset=new Array();
key=document.all.keys.value;
if (key== " "){
alert( "请输入关键字! ");
return;
}
else{
keyset[0]=tempText.indexOf(key,0);
if (keyset[0] <0){
return;
}else
temp=tempText.substring(0,keyset[0]);
temp=temp+h+key+f;
temp2=tempText.substring(keyset[0]+key.length,tempText.length);
for (i=1;i <tempText.length;i++) {
keyset[i]=tempText.indexOf(key,keyset[i-1]+key.length);
if(keyset[i] <0){
temp=temp+tempText.substring(keyset[i-1]+key.length,tempText.length);
break;
}else{
temp=temp+tempText.substring(keyset[i-1]+key.length,keyset[i])+h+key+f;
}
}
world.innerHTML = temp;
}
}
function PageNav(ShowStyle,Page){
//分页码显示函数
//参数为调用样式,0=简单样式,1=标准样式
var temp= " ";
if (ShowStyle==0)
//简单样式
{
tempPage=Page;
if(TotalByte> PageSize){
if (Page-4 <=1){
temp=temp+ " <font face=webdings color=#999999> 9 </font> ";
if (Page <=1){temp=temp+ " <font face=webdings color=#999999> 7 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page-1)+ ")> <font face=webdings> 7 </font> </a> ";}
if (PageCount> 10){
for(i=1;i <8;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
temp=temp+ " ... ";
}
else{
for(i=1;i <PageCount+1;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
}
if (Page==PageCount){temp=temp+ " <font face=webdings color=#999999> 8 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page+1)+ ")> <font face=webdings> 8 </font> </a> ";}
if(PageCount <10){temp=temp+ " <font face=webdings color=#999999> : </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+PageCount+ ")> <font face=webdings> : </font> </a> ";}
}
else if(Page+4 <=PageCount){
temp=temp+ " <a href=javascript:text_pagination(1)> <font face=webdings> 9 </font> </a> ";
temp=temp+ " <a href=javascript:text_pagination( "+(Page-1)+ ")> <font face=webdings> 7 </font> </a> ";
if (PageCount> 10){
temp=temp+ ".. ";
for(i=Page-4;i <Page+4;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
temp=temp+ " .. ";
}
else{
for(i=1;i <PageCount+1;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
}
if (Page==PageCount){temp=temp+ " <font face=webdings color=#999999> 8 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page+1)+ ")> <font face=webdings> 8 </font> </a> ";}
temp=temp+ " <a href=javascript:text_pagination( "+PageCount+ ")> <font face=webdings> : </font> </a> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination(1)> <font face=webdings> 9 </font> </a> ";
temp=temp+ " <a href=javascript:text_pagination( "+(Page-1)+ ")> <font face=webdings> 7 </font> </a> ";
temp=temp+ ".. "
for(i=Page-2;i <PageCount+1;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
if (Page==PageCount){temp=temp+ " <font face=webdings color=#999999> 8 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page+1)+ ")> <font face=webdings> 8 </font> </a> ";}
temp=temp+ " <font face=webdings color=#999999> : </font> ";
}
}
else{
temp=temp+ " <font color=red> 1 </font> ";
}
temp=temp+ " <a href=javascript:text_pagination(0)> 显示全部 </a> "
}
else if (ShowStyle==1)
//标准样式
{
if(TotalByte> PageSize){if(Page!=0){if(Page!=1){temp=temp+ " <a href= '#top ' onclick=javascript:text_pagination( "+(Page-1)+ ")> <font color=3366cc> [上一页] </font> </a> ";}}}
for (i=1;i <PageCount+1 ;i++ )
{
if (Page==i)
{
temp=temp+ " <font color=800000> [ "+i+ "] </font> ";
}
else{
temp=temp+ " <a href= '#top ' onclick=javascript:text_pagination( "+i+ ")> <font color=3366cc> [ "+i+ "] </font> </a> ";
}
}
temp=temp+ " <a name= 'foot '> </a> ";
if(TotalByte> PageSize){if(Page!=0){if(Page!=PageCount){temp=temp+ " <a href= '#top ' onclick=javascript:text_pagination( "+(Page+1)+ ")> <font color=3366cc> [下一页] </font> </a> ";}}}
temp=temp+ " <a href=javascript:text_pagination(0)> <font color=3366cc> 显示全部 </font> </a> "
}
else if (ShowStyle==2)
//下拉菜单样式
{
temp=temp+ ' <select onchange= "text_pagination(this.value) "> '
for (i=1;i <PageCount+1 ;i++ )
{
if (Page==i)
{
temp=temp+ " <option value= ' "+i+ " ' selected style= 'color:red '> 第 "+i+ " 页 "
}
else{
temp=temp+ " <option value= ' "+i+ " '> 第 "+i+ " 页 ";
}
if (PageTitle[i].length!=0)
{
temp=temp+ ': '+PageTitle[i];
}
temp=temp+ " </option> ";
}
temp=temp+ " </select> ";
}
return (temp);
}
if (PageTitle[Page-1].length==0)
{
tempText=Text.substring(PageNum[Page-1]+10,PageNum[Page]);
}
else{
tempText=Text.substring(PageNum[Page-1]+11+PageTitle[Page-1].length,PageNum[Page]);
}
}
}
Output=Output+ " <div id=world> ";
Output=Output+tempText;
Output=Output+ " </div> ";
Output=Output+ " <br> ";
Output=Output+ " <div align=center> ";
Output=Output+PageNav(1,Page);
Output=Output+ " </div> ";
article.innerHTML = Output;
document.location.href= '# ';
eval(document.all.keys).value=key;
if (key!= " "){searchkey();}
}
function searchkey(){
//正文查找函数
h= " <font class=keyworld> ";
f= " </font> ";
keyset=new Array();
key=document.all.keys.value;
if (key== " "){
alert( "请输入关键字! ");
return;
}
else{
keyset[0]=tempText.indexOf(key,0);
if (keyset[0] <0){
return;
}else
temp=tempText.substring(0,keyset[0]);
temp=temp+h+key+f;
temp2=tempText.substring(keyset[0]+key.length,tempText.length);
for (i=1;i <tempText.length;i++) {
keyset[i]=tempText.indexOf(key,keyset[i-1]+key.length);
if(keyset[i] <0){
temp=temp+tempText.substring(keyset[i-1]+key.length,tempText.length);
break;
}else{
temp=temp+tempText.substring(keyset[i-1]+key.length,keyset[i])+h+key+f;
}
}
world.innerHTML = temp;
}
}
function PageNav(ShowStyle,Page){
//分页码显示函数
//参数为调用样式,0=简单样式,1=标准样式
var temp= " ";
if (ShowStyle==0)
//简单样式
{
tempPage=Page;
if(TotalByte> PageSize){
if (Page-4 <=1){
temp=temp+ " <font face=webdings color=#999999> 9 </font> ";
if (Page <=1){temp=temp+ " <font face=webdings color=#999999> 7 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page-1)+ ")> <font face=webdings> 7 </font> </a> ";}
if (PageCount> 10){
for(i=1;i <8;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
temp=temp+ " ... ";
}
else{
for(i=1;i <PageCount+1;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
}
if (Page==PageCount){temp=temp+ " <font face=webdings color=#999999> 8 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page+1)+ ")> <font face=webdings> 8 </font> </a> ";}
if(PageCount <10){temp=temp+ " <font face=webdings color=#999999> : </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+PageCount+ ")> <font face=webdings> : </font> </a> ";}
}
else if(Page+4 <=PageCount){
temp=temp+ " <a href=javascript:text_pagination(1)> <font face=webdings> 9 </font> </a> ";
temp=temp+ " <a href=javascript:text_pagination( "+(Page-1)+ ")> <font face=webdings> 7 </font> </a> ";
if (PageCount> 10){
temp=temp+ ".. ";
for(i=Page-4;i <Page+4;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
temp=temp+ " .. ";
}
else{
for(i=1;i <PageCount+1;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
}
if (Page==PageCount){temp=temp+ " <font face=webdings color=#999999> 8 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page+1)+ ")> <font face=webdings> 8 </font> </a> ";}
temp=temp+ " <a href=javascript:text_pagination( "+PageCount+ ")> <font face=webdings> : </font> </a> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination(1)> <font face=webdings> 9 </font> </a> ";
temp=temp+ " <a href=javascript:text_pagination( "+(Page-1)+ ")> <font face=webdings> 7 </font> </a> ";
temp=temp+ ".. "
for(i=Page-2;i <PageCount+1;i++){
if (i==Page){
temp=temp+ " <font color=red> "+i+ " </font> ";
}
else{
temp=temp+ " <a href=javascript:text_pagination( "+i+ ") > "+i+ " </a> "+ " ";
}
}
if (Page==PageCount){temp=temp+ " <font face=webdings color=#999999> 8 </font> ";}else{temp=temp+ " <a href=javascript:text_pagination( "+(Page+1)+ ")> <font face=webdings> 8 </font> </a> ";}
temp=temp+ " <font face=webdings color=#999999> : </font> ";
}
}
else{
temp=temp+ " <font color=red> 1 </font> ";
}
temp=temp+ " <a href=javascript:text_pagination(0)> 显示全部 </a> "
}
else if (ShowStyle==1)
//标准样式
{
if(TotalByte> PageSize){if(Page!=0){if(Page!=1){temp=temp+ " <a href= '#top ' onclick=javascript:text_pagination( "+(Page-1)+ ")> <font color=3366cc> [上一页] </font> </a> ";}}}
for (i=1;i <PageCount+1 ;i++ )
{
if (Page==i)
{
temp=temp+ " <font color=800000> [ "+i+ "] </font> ";
}
else{
temp=temp+ " <a href= '#top ' onclick=javascript:text_pagination( "+i+ ")> <font color=3366cc> [ "+i+ "] </font> </a> ";
}
}
temp=temp+ " <a name= 'foot '> </a> ";
if(TotalByte> PageSize){if(Page!=0){if(Page!=PageCount){temp=temp+ " <a href= '#top ' onclick=javascript:text_pagination( "+(Page+1)+ ")> <font color=3366cc> [下一页] </font> </a> ";}}}
temp=temp+ " <a href=javascript:text_pagination(0)> <font color=3366cc> 显示全部 </font> </a> "
}
else if (ShowStyle==2)
//下拉菜单样式
{
temp=temp+ ' <select onchange= "text_pagination(this.value) "> '
for (i=1;i <PageCount+1 ;i++ )
{
if (Page==i)
{
temp=temp+ " <option value= ' "+i+ " ' selected style= 'color:red '> 第 "+i+ " 页 "
}
else{
temp=temp+ " <option value= ' "+i+ " '> 第 "+i+ " 页 ";
}
if (PageTitle[i].length!=0)
{
temp=temp+ ': '+PageTitle[i];
}
temp=temp+ " </option> ";
}
temp=temp+ " </select> ";
}
return (temp);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询