前个时间发表了一个ASp版本的,可还是有破坏标签的 时候,于是写了一个js的。
代码如下面:
使用:把代码放到网页的下面。
[Code]<Script language="javascript">
function autoSplit_js(){
var LogObj = "AS_ContentDiv272"
var MaxNum = 2000;
//var MaxNum = ASCore.BlogAutoCutWordNum
//autoPage=false;
//if (MaxNum>0 ){ autoPage=true}
//var LogObj = "AS_ContentDiv{$LogID}"
var LogContent= document.getElementById(LogObj).innerHTML;
var iChar=LogContent.length;
var AutoPageStr="<br>";
//if(autoPage==true){
var arrContnet=new Array()
//否是有手动分页标志:[NextPage]
if(LogContent.indexOf("[NextPage]")>0 ){
alert("有手动标志。");
var arr = LogContent.split("[NextPage]");
parts = arr.length;
alert(parts)
for(var i=1;i<=parts;i ){
arrContnet[i] =arr[i-1];
AutoPageStr = "<span> <a href=’javascript:void(0)’ onclick=’ToPage(" i ")’>第" i "页</a> </span>";
}
document.getElementById(LogObj).innerHTML=""
document.getElementById(LogObj).innerHTML = arrContnet[1] AutoPageStr;
//for(
}else{
alert("没有手动标志。");
var parts = parseInt(iChar/MaxNum)
if(parts > parseInt(iChar/MaxNum)*1.1){
parts = parts 1;
}else{
parts = parseInt(iChar/MaxNum);
}
//如果达到分页的限制
if(parts>1){
for(var i=1;i<=parts;i ){
arrContnet[i] = LogContent.substring((i-1)*2000, i*2000);
AutoPageStr = "<span> <a href=’javascript:void(0)’ onclick=’ToPage(" i ")’>第" i "页</a> </span>";
}
document.getElementById(LogObj).innerHTML=""
document.getElementById(LogObj).innerHTML = arrContnet[1] AutoPageStr;
}//如果达到分页的限制结束
}
//}
ToPage=function(a){
document.getElementById(LogObj).innerHTML=""
document.getElementById(LogObj).innerHTML=arrContnet[a] AutoPageStr;
}
}
autoSplit_js();
</Script>
<div id="AS_ContentDiv272">,,这里是文章</div>
[/Code]
评论前必须登录!
注册