5 个解决方案
#1
建议使用JS数组来解决这个问题,效果非常好,你使用STREAM也不能提高很多的。
#2
同意你的看法,但是现在需要短时间解决这个问题,我也想用ASP实现,当作一个功能的实现方式,现在再去动原代码,时间上也来不及了。
#3
不是很复杂呀,就用标准的fso操作就可以了,先用一个字符串对象保存生成的内容,然后写入到一个file中就行了,用textstream对象不如直接用file方便
#4
Function newsTextFun(strTitle,strTime,strContent,strPic,strTemplate)
strNews = "<HTML><HEAD><TITLE>" & strTitle & "</TITLE></HEAD><BODY>"
If strTemplate = "0" Then
strNews = strNews & "<DIV ALIGN='CENTER'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
strNews = strNews & "<TD WIDTH='100%'>"
strNews = strNews & "<P ALIGN='CENTER'><B>" & strTitle & "</B></P>"
strNews = strNews & "<P ALIGN='CENTER' STYLE='FONT-SIZE:13PX;'>" & strTime & "</P>"
strNews = strNews & "<P ALIGN='CENTER'><IMG SRC='IMAGES\" & strPic &"' ALT='ZOOM OUT'></IMG></P>"
strNews = strNews & strContent
strNews = strNews & "</TD></TR></TABLE></DIV>"
' ****** ADD THE FOOT BAR ************
'strNews = strNews & "<BR><DIV ALIGN='RIGHT'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
'strNews = strNews & "<TD WIDTH='100%' ALIGN='RIGHT'><P ALGIN='RIGHT' STYLE='FONT-SIZE:13PX;'>"
'strNews = strNews & "【<A HREF='sendme.asp?newsTitle='" & strTitle &"'><FONT COLOR='BLACK'>发到信箱</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.print();'><FONT COLOR='BLACK'>打印文档</FONT></A>】 "
'strNews = strNews & "【<A HREF='send.asp?newsTitle='" & strTitle & "'><FONT COLOR='BLACK'>推荐朋友</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.close();'><FONT COLOR='BLACK'>关闭窗口</FONT></A>】 "
'strNews = strNews & "</P></TD></TR></TABLE></DIV>"
ElseIf strTemplate = "1" Then
ElseIf strTemplate = "2" Then
ElseIf strTemplate = "3" Then
ElseIf strTemplate = "4" Then
Else
End IF
strNews = strNews & "</BODY></HTML>"
newsTextFun = strNews
End Function
newsText = newsTextFun(newsTitle,newsTime,newsContent,newsPic,newsTemplate)
Set fso = CreateObject("Scripting.FileSystemObject")
Set out = fso.CreateTextFile(strNewsFile)
out.Write newsText
out.Close
set out = Nothing
strNews = "<HTML><HEAD><TITLE>" & strTitle & "</TITLE></HEAD><BODY>"
If strTemplate = "0" Then
strNews = strNews & "<DIV ALIGN='CENTER'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
strNews = strNews & "<TD WIDTH='100%'>"
strNews = strNews & "<P ALIGN='CENTER'><B>" & strTitle & "</B></P>"
strNews = strNews & "<P ALIGN='CENTER' STYLE='FONT-SIZE:13PX;'>" & strTime & "</P>"
strNews = strNews & "<P ALIGN='CENTER'><IMG SRC='IMAGES\" & strPic &"' ALT='ZOOM OUT'></IMG></P>"
strNews = strNews & strContent
strNews = strNews & "</TD></TR></TABLE></DIV>"
' ****** ADD THE FOOT BAR ************
'strNews = strNews & "<BR><DIV ALIGN='RIGHT'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
'strNews = strNews & "<TD WIDTH='100%' ALIGN='RIGHT'><P ALGIN='RIGHT' STYLE='FONT-SIZE:13PX;'>"
'strNews = strNews & "【<A HREF='sendme.asp?newsTitle='" & strTitle &"'><FONT COLOR='BLACK'>发到信箱</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.print();'><FONT COLOR='BLACK'>打印文档</FONT></A>】 "
'strNews = strNews & "【<A HREF='send.asp?newsTitle='" & strTitle & "'><FONT COLOR='BLACK'>推荐朋友</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.close();'><FONT COLOR='BLACK'>关闭窗口</FONT></A>】 "
'strNews = strNews & "</P></TD></TR></TABLE></DIV>"
ElseIf strTemplate = "1" Then
ElseIf strTemplate = "2" Then
ElseIf strTemplate = "3" Then
ElseIf strTemplate = "4" Then
Else
End IF
strNews = strNews & "</BODY></HTML>"
newsTextFun = strNews
End Function
newsText = newsTextFun(newsTitle,newsTime,newsContent,newsPic,newsTemplate)
Set fso = CreateObject("Scripting.FileSystemObject")
Set out = fso.CreateTextFile(strNewsFile)
out.Write newsText
out.Close
set out = Nothing
#5
<%
set MyFileObject=server.createobject("Scripting.FileSystemObject")
set MyTextFile=MyFileObject.CreateTextFile("c:\test\test.htm")
MyTextFile.WriteLine("<html>")
MyTextFile.WriteLine("<head>")
MyTextFile.WriteLine("</head>")
MyTextFile.WriteLine("<body>")
……
MyTextFile.WriteLine("</body>")
MyTextFile.WriteLine("</html>")
MyTextFile.close
%>
唉,苦命啊,就是这样就可以写出来了,谢谢大家了,所以把代码贴出来给大家看看。
set MyFileObject=server.createobject("Scripting.FileSystemObject")
set MyTextFile=MyFileObject.CreateTextFile("c:\test\test.htm")
MyTextFile.WriteLine("<html>")
MyTextFile.WriteLine("<head>")
MyTextFile.WriteLine("</head>")
MyTextFile.WriteLine("<body>")
……
MyTextFile.WriteLine("</body>")
MyTextFile.WriteLine("</html>")
MyTextFile.close
%>
唉,苦命啊,就是这样就可以写出来了,谢谢大家了,所以把代码贴出来给大家看看。
#1
建议使用JS数组来解决这个问题,效果非常好,你使用STREAM也不能提高很多的。
#2
同意你的看法,但是现在需要短时间解决这个问题,我也想用ASP实现,当作一个功能的实现方式,现在再去动原代码,时间上也来不及了。
#3
不是很复杂呀,就用标准的fso操作就可以了,先用一个字符串对象保存生成的内容,然后写入到一个file中就行了,用textstream对象不如直接用file方便
#4
Function newsTextFun(strTitle,strTime,strContent,strPic,strTemplate)
strNews = "<HTML><HEAD><TITLE>" & strTitle & "</TITLE></HEAD><BODY>"
If strTemplate = "0" Then
strNews = strNews & "<DIV ALIGN='CENTER'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
strNews = strNews & "<TD WIDTH='100%'>"
strNews = strNews & "<P ALIGN='CENTER'><B>" & strTitle & "</B></P>"
strNews = strNews & "<P ALIGN='CENTER' STYLE='FONT-SIZE:13PX;'>" & strTime & "</P>"
strNews = strNews & "<P ALIGN='CENTER'><IMG SRC='IMAGES\" & strPic &"' ALT='ZOOM OUT'></IMG></P>"
strNews = strNews & strContent
strNews = strNews & "</TD></TR></TABLE></DIV>"
' ****** ADD THE FOOT BAR ************
'strNews = strNews & "<BR><DIV ALIGN='RIGHT'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
'strNews = strNews & "<TD WIDTH='100%' ALIGN='RIGHT'><P ALGIN='RIGHT' STYLE='FONT-SIZE:13PX;'>"
'strNews = strNews & "【<A HREF='sendme.asp?newsTitle='" & strTitle &"'><FONT COLOR='BLACK'>发到信箱</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.print();'><FONT COLOR='BLACK'>打印文档</FONT></A>】 "
'strNews = strNews & "【<A HREF='send.asp?newsTitle='" & strTitle & "'><FONT COLOR='BLACK'>推荐朋友</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.close();'><FONT COLOR='BLACK'>关闭窗口</FONT></A>】 "
'strNews = strNews & "</P></TD></TR></TABLE></DIV>"
ElseIf strTemplate = "1" Then
ElseIf strTemplate = "2" Then
ElseIf strTemplate = "3" Then
ElseIf strTemplate = "4" Then
Else
End IF
strNews = strNews & "</BODY></HTML>"
newsTextFun = strNews
End Function
newsText = newsTextFun(newsTitle,newsTime,newsContent,newsPic,newsTemplate)
Set fso = CreateObject("Scripting.FileSystemObject")
Set out = fso.CreateTextFile(strNewsFile)
out.Write newsText
out.Close
set out = Nothing
strNews = "<HTML><HEAD><TITLE>" & strTitle & "</TITLE></HEAD><BODY>"
If strTemplate = "0" Then
strNews = strNews & "<DIV ALIGN='CENTER'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
strNews = strNews & "<TD WIDTH='100%'>"
strNews = strNews & "<P ALIGN='CENTER'><B>" & strTitle & "</B></P>"
strNews = strNews & "<P ALIGN='CENTER' STYLE='FONT-SIZE:13PX;'>" & strTime & "</P>"
strNews = strNews & "<P ALIGN='CENTER'><IMG SRC='IMAGES\" & strPic &"' ALT='ZOOM OUT'></IMG></P>"
strNews = strNews & strContent
strNews = strNews & "</TD></TR></TABLE></DIV>"
' ****** ADD THE FOOT BAR ************
'strNews = strNews & "<BR><DIV ALIGN='RIGHT'><TABLE BORDER='0' CELLPADDING='0' CELLSPACING='0' WIDTH='96%'><TR>"
'strNews = strNews & "<TD WIDTH='100%' ALIGN='RIGHT'><P ALGIN='RIGHT' STYLE='FONT-SIZE:13PX;'>"
'strNews = strNews & "【<A HREF='sendme.asp?newsTitle='" & strTitle &"'><FONT COLOR='BLACK'>发到信箱</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.print();'><FONT COLOR='BLACK'>打印文档</FONT></A>】 "
'strNews = strNews & "【<A HREF='send.asp?newsTitle='" & strTitle & "'><FONT COLOR='BLACK'>推荐朋友</FONT></A>】 "
'strNews = strNews & "【<A HREF='#' ONCLICK='javascript:window.close();'><FONT COLOR='BLACK'>关闭窗口</FONT></A>】 "
'strNews = strNews & "</P></TD></TR></TABLE></DIV>"
ElseIf strTemplate = "1" Then
ElseIf strTemplate = "2" Then
ElseIf strTemplate = "3" Then
ElseIf strTemplate = "4" Then
Else
End IF
strNews = strNews & "</BODY></HTML>"
newsTextFun = strNews
End Function
newsText = newsTextFun(newsTitle,newsTime,newsContent,newsPic,newsTemplate)
Set fso = CreateObject("Scripting.FileSystemObject")
Set out = fso.CreateTextFile(strNewsFile)
out.Write newsText
out.Close
set out = Nothing
#5
<%
set MyFileObject=server.createobject("Scripting.FileSystemObject")
set MyTextFile=MyFileObject.CreateTextFile("c:\test\test.htm")
MyTextFile.WriteLine("<html>")
MyTextFile.WriteLine("<head>")
MyTextFile.WriteLine("</head>")
MyTextFile.WriteLine("<body>")
……
MyTextFile.WriteLine("</body>")
MyTextFile.WriteLine("</html>")
MyTextFile.close
%>
唉,苦命啊,就是这样就可以写出来了,谢谢大家了,所以把代码贴出来给大家看看。
set MyFileObject=server.createobject("Scripting.FileSystemObject")
set MyTextFile=MyFileObject.CreateTextFile("c:\test\test.htm")
MyTextFile.WriteLine("<html>")
MyTextFile.WriteLine("<head>")
MyTextFile.WriteLine("</head>")
MyTextFile.WriteLine("<body>")
……
MyTextFile.WriteLine("</body>")
MyTextFile.WriteLine("</html>")
MyTextFile.close
%>
唉,苦命啊,就是这样就可以写出来了,谢谢大家了,所以把代码贴出来给大家看看。