关闭

JS+ASP 实现超长文章自动分页

966人阅读 评论(0) 收藏 举报

JavaScript脚本部分
======================
function submitPostIfRame(mode){
 var sMarkup = doc_html.getHTML();  //从html编辑器中取数据
 with(document.forms[0]){
  doc_html.document.open();
  doc_html.document.write(sMarkup);
  doc_html.document.close();
  doc_html.document.body.innerHTML = sMarkup;
  var oBody=doc_html.document.body;
  var oHTML="";
  for(var i=0;i<oBody.childNodes.length;i++){
   if(i!=oBody.childNodes.length-1){
    if(oBody.childNodes[i].nodeType==3){
     oHTML+=oBody.childNodes[i].nodeValue+"{#CMS-PAGINATION-SYMBOL#}";
    }else{
     oHTML+=oBody.childNodes[i].outerHTML+"{#CMS-PAGINATION-SYMBOL#}";
    }
   }else{
    if(oBody.childNodes[i].nodeType==3){
     oHTML+=oBody.childNodes[i].nodeValue;
    }else{
     oHTML+=oBody.childNodes[i].outerHTML;
    }
   }
  }
  news_content.value = oHTML
 }
 return true;
}
ASP脚本部分
===============
Function calculate_pagination(strContent, pSize)
    On Error Resume Next
    Dim aCon, intfor, intCount, strTemp, strTemp2
    aCon = Split(strContent, "{#CMS-PAGINATION-SYMBOL#}", -1, 1)
    intCount = UBound(aCon)
    strTemp = ""
    strTemp2 = ""
    Page = 1
    For intfor = 0 To intCount
        strTemp = strTemp & aCon(intfor)
        strTemp2 = strTemp2 & RemoveHTML(aCon(intfor))
        'strTemp2 = strTemp2 & aCon(intFor)
        If Len(strTemp2) >= pSize Then
            Page = Page + 1
            strTemp = ""
            strTemp2 = ""
        End If
    Next
    'If strTemp2 <> "" Then Page = Page - 1
    calculate_pagination = Page
    If Err.Number <> 0 Then
        calculate_pagination = 1
        Err.Clear
    End If
End Function

Function get_page_text(strContent, pagenum, totalpage, pSize)
    aCon = Split(strContent, "{#CMS-PAGINATION-SYMBOL#}", -1, 1)
    intCount = UBound(aCon)
    strTemp = ""
    strTemp2 = ""
    Page = 1
    For intfor = 0 To intCount
        strTemp = strTemp & aCon(intfor)
        strTemp2 = strTemp2 & RemoveHTML(aCon(intfor))
        'strTemp2 = strTemp2 & aCon(intFor)
        If Len(strTemp2) >= pSize Then
            If pagenum = Page Then
                get_page_text = strTemp
                Exit For
            End If
            Page = Page + 1
            strTemp = ""
            strTemp2 = ""
        End If
    Next
    If strTemp2 <> "" And pagenum > Page - 1 Then get_page_text = strTemp
End Function


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:39728次
    • 积分:466
    • 等级:
    • 排名:千里之外
    • 原创:1篇
    • 转载:31篇
    • 译文:0篇
    • 评论:1条
    最新评论