<%
dim kind, path,classID,NclassID
kind=1 '首页调用类型,1表示新文章,2表示热门文章
const dateNum=10 '列出多少天内的热门文章
const maxLen=30 '主题最多显示字数,字母算一个汉字算两个
const listNum=5 '显示多少个文章标题
const bullet="·" '标题前的图片或符号
const hitColor="red" '点击数的颜色
const new_color="red" '新文章日期的颜色
const old_color="gray" '旧文章日期的颜色
const showNclass=true '是否显示专题连接
ClassID=request.querystring("classid") '指定首页调用文章分类ID,全部分类不填
NclassID=request.querystring("nclassid")
dim rs,sql,str,str1,topicLen,topic
Path="http://";;&request.servervariables("server_name")&replace(request.servervariables("script_name"),"js.asp","")
function gotTopic(str,strlen)
dim l,t,c, i
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i)&"..."
exit for
else
gotTopic=str
end if
next
end function
set rs=server.createObject("Adodb.recordset")
sql="select top "&listNum&" articleID,title,dateAndtime,hits,nclass,article.nclassid,article.classid from ANclass inner join article on article.nclassid=anclass.nclassid"
if NclassID<>"" then
sql=sql&" where article.NclassID="&NclassID
elseif classID<>"" then
sql=sql&" where article.classID="&classID
end if
if kind=2 then
if nclassid="" and classID="" then
sql=sql&" where"
else
sql=sql&" and"
end if
end if
select case kind
case "1" sql=sql&" order by articleid desc"
case "2" sql=sql&" DATEDIFF('d',dateandtime,Now())<="&dateNum&" order by hits desc,title"
end select
rs.open sql,conn,3,3
if rs.bof and rs.eof then
str=str+"没有符合条件的文章"
else
rs.movefirst
do while not rs.eof
topic=gotTopic(rs("title"),maxLen)
topic=replace(server.HTMLencode(topic)," "," ")
topic=replace(topic,"'"," ")
str=str+bullet
if showNclass then
str=str+"[
"&rs("nclass")&"] "
end if
str=str+"
"+Topic+" ("
str=str & "
=date then
str=str & new_color
else
str=str & old_color
end if
str=str &">" & Month(rs("DateAndTime"))&"月"&Day(rs("DateAndTime"))&"日,
"& rs("hits") &")
"
rs.moveNext
loop
end if
rs.close : conn.close
set rs=nothing : set conn=nothing
response.write "document.write ("&Chr(34)&str&Chr(34)&");"
%>
上面我是用来动网新闻首页调用的JS程序。但是我希望在调用出来的5条新闻里面的第一条新闻后面加个NEW的图片不知道哪位会的帮帮兄弟我,这个是大家学习的机会啊。