ASP输出JS,具体如何?
ASP文件是:
<!--#include file="conn.asp"-->
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<%
sql="select id,title,shijian from wenzhang where Class2ID=25 order by id desc"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,2
if rs.eof then
response.Write("暂时没有相关文章!")
else
i=0
while not rs.eof and i<12
i=i+1
%>
<tr>
<td width="92%"><a href="newslist.asp?id=<%=rs("id")%>" title="<%=rs("title")%>"><%= mid(rs("title"),1,18) %></a></td>
<td width="8%">
<div align="right">
<p align="left"><font color="#CCCCCC"><%=day(rs("shijian"))%>日</font></div></td>
</tr>
<% rs.movenext
wend
end if
rs.close %>
</table>
参考答案:asp语句是用<% %>包起来的。
所以输出js就和静态html一样,<script>js代码</script>。
别把js放进<% %>里面就行了。