首先来看一下这个实现的思路:1.在所有有是示新闻标题的页面的最后面加上一个<iframe>2.写一个JS函数可以传递新闻ID,通过这段代码document.getElementByIdx("addnewsnum").src="/include/addnewsnum.asp?newsid="+newsid来刷新IFRMAE里的页面,并在每条新闻的点击事件上应用这个JS函数以下是JS函数:function addclick(newsid){ document.getElementByIdx("addnewsnum").src="<%=sitehead%>/include/addnewsnum.asp?newsid="+newsid }以下是ASP页面中代码:<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file="conn.asp" --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>添加点击</title> </head><body> <% newsid=Request.QueryString("newsid") if newsid<>"" then sql="select * from comnews where newsid="&newsid set rs=conn.execute(sql) if not rs.eof and not rs.bof then sql="update comnews set clicks=clicks+1 where newsid="&newsid conn.execute(sql) end if clsrs clsconn end if %> </body> </htm>
document.getElementByIdx("addnewsnum").src="<%=sitehead%>/include/addnewsnum.asp?newsid="+newsid
}以下是ASP页面中代码:<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>添加点击</title>
</head><body>
<%
newsid=Request.QueryString("newsid")
if newsid<>"" then
sql="select * from comnews where newsid="&newsid
set rs=conn.execute(sql)
if not rs.eof and not rs.bof then
sql="update comnews set clicks=clicks+1 where newsid="&newsid
conn.execute(sql)
end if
clsrs
clsconn
end if
%>
</body>
</htm>