Pcook CMS V2.3 Beta 上线测试!
您现在的位置:首页 >> 编程技巧 >> 信息正文

超长文章内容如何进行分页并生成HTML文件

2008-11-2 15:10:30 来源: 网络 作者:站长 访问:155 次 被顶:10 次 字号:【

<%  
dim fname,fso,fout,htmlcode  
dim htmlbody,htmlbody1,page_n  
htmlbody=request.form("body")  
page_n=len(htmlbody)-len(replace(htmlbody,"$",""))  
’生成文件名的函数  
function makefilename(fname)  
fname = fname  
fname = replace(fname,"-","")  
fname = replace(fname," ","")  
fname = replace(fname,":","")  
fname = replace(fname,"PM","")  
fname = replace(fname,"AM","")  
fname = replace(fname,"上午","")  
fname = replace(fname,"下午","")  
makefilename=fname  
end function  
if request.querystring("action")="add" then  
for i=0 to page_n  
fname=makefilename(now())  
if i=0 then  
ppage=0  
else  
ppage=i-1  
end if  
if i=0 and page_n>i then  
npage=i+1  
else  
npage=page_n  
end if  
shtml=split(htmlbody,"$")(i) & vbcrlf  
shtml=shtml&"<br><a href="""&fname&"_"&ppage&".html"">上一页</a> <a href="""&fname&"_"&npage&".html"">下一页</a>"  
Set fso = Server.CreateObject("Scripting.FileSystemObject")  
Set fout = fso.CreateTextFile(Server.MapPath(fname&"_"&i&".html"))  
fout.WriteLine shtml  
fout.close  
next  
response.write"<SCRIPT language=javascript>alert(’成功生成"&page_n+1&"个HTML页’);this.location.href=’javascript:history.back();’</SCRIPT>"  
end if  
%>  
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">  
<title>超长文件分页并生成HTML文件简单示例</title>  
</head>  
<body>  
<form name="form1" method="post" action="?action=add">  
文章内容:  
<br>  
<textarea name="body" cols="60" rows="8">  
第一页内容  
$  
第二页内容  
$  
第三页内容</textarea>  
<br>  
<input type="submit" name="Submit" value="提交">  
</form>  
</body>  
</html>

打印本文   加入收藏   返回顶部   关闭窗口Tags:生成HTML|分页  
相关文章列表
参与评论
网友评论列表
© CopyRight 2008 Pcook.com.cn, Inc.All Rights Reserved.
Powered by:laoy8 Design by:Pcook 沪ICP备08004247号