ASP写文件CreateTextFile遇到的问题

来源:百度知道 编辑:UC知道 时间:2024/07/04 21:11:01
index.asp文件内容:
=============================
<!--#include file="1.htm"-->
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set tmp = fso.OpenTextFile(Server.MapPath("1.htm"))
If Not tmp.AtEndOfStream then
body=tmp.ReadAll
End If

Set fs = Server.CreateObject("Scripting.FileSystemObject")
tid = server.mappath("2.htm")
Set a = fs.CreateTextFile(tid)
a.Write body
a.close
set fs=nothing
%>

=======================================

以下是1.htm内容
--------------------------------
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<% Response.Write date() %>
</body>
</html>
-----------------------------------

当运行index.asp时 显示1.htm 为当前时间 2009-7

用replace将body中的<% Response.Write date() %>替换成当前时间

你的1.html不能解释<%%>因为是html静态的,建议用js
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var now= new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var day=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
document.write(year+"-"+month+"-"+day+" "+hour+":"+":"+minute+":"+second);
-->
</SCRIPT>
</body>
</html>