一聚教程网:一个值得你收藏的教程网站

热门教程

ASP内容分页函数

时间:2022-06-29 14:24:18 编辑:袖梨 来源:一聚教程网

  1. <%   
  2. '==============================================   
  3. '函数名:contentpage   
  4. '作  用:内容分页   
  5. '参  数:1、ocontent ----- 文章内容   
  6. '   2、olink  ----- 链接   
  7. '整  理:www.asp教程program.cn   
  8. '原创文章,转载请保留此信息,谢谢   
  9. '==============================================   
  10.   
  11. function contentpage(ocontent, olink)   
  12.     dim outstr, arrcontent, nextpage, arrpage   
  13.     if instr(ocontent, "[nextpage]") <= 0 then  
  14.         outstr = ocontent   
  15.     else  
  16.         nextpage = request("nextpage")   
  17.         arrcontent = split(ocontent, "[nextpage]")   
  18.         arrpage = ubound(arrcontent) + 1   
  19.         if (nextpage = "" or isnull(nextpage) or not isnumeric(nextpage)) then  
  20.             nextpage = 1   
  21.         else  
  22.             nextpage = cint(nextpage)   
  23.         end if  
  24.         if nextpage < 1 then  
  25.             nextpage = 1   
  26.         end if  
  27.         if nextpage > arrpage then  
  28.             nextpage = arrpage   
  29.         end if  
  30.         outstr = arrcontent(nextpage - 1)   
  31.         outstr = outstr "
    "
      
  32.         for iii = 1 to arrpage   
  33.             if iii = nextpage then  
  34.                 outstr = outstr ""red"">"&iii" "  
  35.             else  
  36.                 outstr = outstr """&olink"nextpage="&iii""">"&iii" "  
  37.             end if  
  38.         next  
  39.     end if  
  40.     contentpage = outstr   
  41. end function  
  42.   
  43. '=================demo==================   
  44. dim sstrhtml, ostrhtml   
  45. sstrhtml = "我的名字叫胡浪[nextpage]胡是古月的胡[nextpage]浪是三点水一个良字的浪[nextpage]不是一个帅哥哦[nextpage]很普通的一个人"  
  46. ostrhtml = "我的名字叫胡浪,胡是古月的胡,浪是三点水一个良字的浪,不是一个帅哥哦,很普通的一个人"  
  47. '=================demo==================   
  48. response.write("------------------- 带分页 ---------------------")   
  49. response.write("
    "
    )   
  50. response.write(contentpage(sstrhtml, "?"))   
  51. response.write("
    "
    )   
  52. response.write("------------------- 不带分页 ---------------------")   
  53. response.write("
    "
    )   
  54. response.write(contentpage(ostrhtml, "?"))   
  55. %>  

热门栏目