28,406
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>{Test_Title}</title>
<meta name="keywords" content="{Test_Keywords}" />
<meta name="description" content="{Test_Description}" />
</head>
<body>
{Test_ConTent}
</body>
</html><%
'==========================================================
'函数名:ReadtxtFiles
'函数作用:读取文件
'参数:Filename 文件路径
'==========================================================
Function ReadtxtFiles(Filename)
Dim fso,ts
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(Server.MapPath(Filename), ForReading)
ReadtxtFiles = ts.ReadAll
ts.Close
End Function
'==========================================================
'函数名:CreateFile
'函数作用:写入文件
'参数:Filename 文件路径,temp 文件内容
'==========================================================
Function CreateFile(Filename,temp)
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile(Server.MapPath(Filename), True)
tf.write temp
tf.Close
CreateFile=Filename
End Function
%>
<%
'调用ReadtxtFiles函数,读取文件
Temp=ReadtxtFiles("Index.html")
'定义4个测试变量并赋值 Start
Test_Title="那是个畜生"
Test_Keywords="本来就是个畜生"
Test_Description="是个畜生"
Test_ConTent="真TMD畜生一个!"
'定义4个测试变量并赋值 End
'替换上面的4个变量 Start
Temp=Replace(Temp,"{Test_Title}",Test_Title)
Temp=Replace(Temp,"{Test_Keywords}",Test_Keywords)
Temp=Replace(Temp,"{Test_Description}",Test_Description)
Temp=Replace(Temp,"{Test_ConTent}",Test_ConTent)
'替换上面的4个变量 End
'调用CreateFile函数,CreateFile的参数及作用已经写在上面了
Call CreateFile("CreateHtml.html",Temp)
'如果没有创建出:CreateHtml.html文件,请检查权限
'好了.到这里就结束了.你看可以利用这个例子做一个新闻发布系统了.
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>那是个畜生</title>
<meta name="keywords" content="本来就是个畜生" />
<meta name="description" content="是个畜生" />
</head>
<body>
真TMD畜生一个!
</body>
</html>