两个文件:
creatjs.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#999999">
<tr>
<td bgcolor="#FFFFFF"><form action="creatjs.asp" method="post" enctype="application/x-www-form-urlencoded" name="form1">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
<tr bgcolor="#FFFFFF">
<td width="40%"><div align="right">html文件:</div></td>
<td width="60%"><input type="file" name="infile"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td><div align="right">目标文件:</div></td>
<td><input type="text" name="outfile"><!--设计要生成JS文件的名字如:test.js--></td>
</tr>
<tr bgcolor="#FFFFFF">
<td> </td>
<td><input type="submit" name="Submit" value="确定"></td>
</tr>
</table>
<br>
</form></td>
</tr>
</table>
</body>
</html>
creatjs.asp
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<%
infile=request.Form("infile")
outfile=request.Form("outfile")
response.Write(infile&"..........."&outfile&"<br>")
%>
<body>
<%
set fs=server.createobject("scripting.filesystemobject")
' countfile=server.mappath(infile)
set txt=fs.OpenTextFile(infile)
set out = fs.Createtextfile(server.MapPath("../js/"&outfile),8, TRUE)
do until txt.AtEndOfStream
s=txt.ReadLine
s=replace(s,"' ","/' ")
s2="document.write(' "&s&"' )"
response.Write(s&chr(13))
out.writeline(s2)
loop
txt.close
out.close
set fs=nothing
%>
<script src="../js/<%=outfile%>" language="javascript"></script>
</body>
</html>
更多的使用asp将html文件生成js文件请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2008-1-30