index.asp页面要调用新闻,我写在news.asp里面,然后在index.asp里面
<script language="javascript" src="article/News.asp?Sid=8&Num=5"></script>
其中8是文章分类id,5是文章数
News.asp里面

<%
Sid=Request.QueryString("Sid")
listNum=Request.QueryString("Num")

Sql="SELECT TOP "& listNum &" title,articleid FROM Article WHERE Sid="& Sid& " ORDER BY hits desc,articleid asc"

Set Rs=Server.CreateObject("ADODB.Recordset")
Rs.Open Sql,Conn,1,1

Response.Write"document.write('<table width=""100%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""0"">');"
Do while not Rs.eof
%>
document.write('<tr><td height="18"><img src="image/dot.gif" /><a href="article/read.asp?id=<%=Rs("articleid")%>" target="_blank" title="<%=Replace(Rs("title"),"'","")%>"><%=getchar(Replace(Rs("title"),"'",""),45)%></a></td></tr>');
<%
Rs.movenext
loop
Response.Write"document.write('</table>');"
Rs.close
Set Rs=nothing
Call CloseConn
%>
getchar 是取文章标题长度的
现在问题是我要把index.asp生成index.shtm,基本上正常,除了<script language……的地方,因为浏览器把它当js
我生成一个页面是采用这个方法
引用:
'输入url目标网页地址,返回值getHTTPPage是目标网页的html代码
Function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
If Http.readystate<>4 then
exit function
End If
getHTTPPage = Bytestobstr(Http.ResponseBody,"UTF-8")
'转换.asp2.shtm
getHTTPPage = Replace(getHTTPPage,".asp",".shtm")
Set Http=nothing
If err.number<>0 Then err.Clear
End Function

'转换编码(乱码)函数
Function Bytestobstr(Body,Cset)
Dim Objstream
Set Objstream = Server.Createobject("Adodb.Stream")
Objstream.Type = 1
Objstream.Mode =3
Objstream.Open
Objstream.Write Body
Objstream.Position = 0
Objstream.Type = 2
Objstream.Charset = Cset
Bytestobstr = Objstream.Readtext
Objstream.Close
Set Objstream = Nothing
End Function