关于asp的一个奇怪现象
我在首页使用 <script language= "javascript " src= 'admin/news.asp?newstype=新闻&typeid=1&n=5 '> </script> 调用news.asp,当有记录时,可以显示;但是,当无记录时,无法按照程序设计显示。大家帮忙一下。news.asp代码如下:
javastr= " <style> A.menu2{text-decoration: none;color:#000099;line-height: 25pt;font-size:9pt} A.menu2:hover {text-decoration: none;line-height: 25pt;font-size:9pt;color: #ffffff}A.menu2:visited {color:#FF66cFF;line-height: 25pt;font-size:9pt} </style> "
javastr=javastr+ " <table width=\ "100%\ " border=\ "0\ "> "
<!--#include file= "../connection/conn.asp "-->
<%newstype=request( "typeid ")
n=request( "n ")
if newstype <> " " then
sql= "select * from article where shenhe=1 and artical_type_id= "+cstr(newstype)+ " order by dateandtime desc "
set rs=conn.execute(sql)
if rs.eof and rs.bof then%>
document.Write( " <div align=center> 暂时没有新闻 </div> ")
<%end if%>
<%do while not rs.eof
%>
javastr=javastr+ " <tr> <td> "
javastr=javastr+ " <img src=\ "images/label.gif\ " width=\ "10\ " height=\ "10\ " > <span style=\ "font-size:9pt;line-height: 15pt\ "> <%if rs( "selectpicture ") = 1 then%> [图文] <%end if%> <a href=\ "open.asp?id= <%=rs( "artical_id ")%> &path= <%=rs( "artical_path ")%> &filename= <%=rs( "artical_filename ")%> \ ") target=\ "_blank\ " > <%=rs( "artical_title ")%> </a> </span> <font color=\ "#999999\ " font size=\ "1\ "> ( <%=rs( "dateandtime ")%> )(阅读: <%=rs( "hits ")%> ) </font> "
javastr=javastr+ " </td> </tr> "
<%n=n-1
if n <1 then exit do
rs.movenext
loop
%>
<%rs.close
set rs=nothing
conn.close
set conn=nothing%>
javastr=javastr+ " </table> "
document.write (javastr)
<%else%>
document.write ( "对不起,暂时没有任何内容。 ")
<%end if%>
------解决方案--------------------
if rs.eof and rs.bof then%>
document.Write( " <div align=center> 暂时没有新闻 </div> ")
<%end if%>
<%do while not rs.eof
%>
javastr=javastr+ " <tr> <td> "
----------------------------
你没记录时结果成了 <table> <div align=center> 暂时没有新闻 </div> </table> 怎么能正常显示?
改document.Write( " <tr> <td> 暂时没有新闻 </td> </tr> ")