超长文章(HTML格式)自动分页,用ASP和JS实现 来源
本站原创 佚名
20040517001558-101502.html
20040517001558-101502_2.html
20040517001558-101502_3.html
20040517001558-101502_4.html
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 if(i!=oBody.childNodes.length-1){ if(oBody.childNodes[i].nodeType==3){ oHTML+=oBody.childNodes[i].nodeValue+""; }else{ oHTML+=oBody.childNodes[i].outerHTML+""; } }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, "", -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, "", -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
|
关联文档