您的位置:首页 > Web前端 > JavaScript

首页JS新闻代码

2016-06-02 12:47 489 查看
JS分类调用说明:

1,一级分类调用:

<script language="javascript"
src="owen.asp?owen1=国内新闻&n=6"></script>

表示调用一级分类中的 国内新闻 6条

2,二级分类调用:

<script language="javascript"
src="owen.asp?owen1=国内新闻&owen2=本地新闻&n=8"></script>

表示调用 国内新闻 下的二级分类 本地新闻 8条

3,最新新闻调用:

<script language="javascript"
src="owen.asp?n=10"></script>

表示调用10条最新新闻

代码部分:

javastr=""

javastr=javastr+"<table width=\"100%\" border=\"0\"
cellpadding=\"0\" cellspacing=\"0\">"

<!--#include file="conn.asp"-->

<%

owen=request("owen")

owen1=request("owen1")

owen2=request("owen2")

n=request("n")

if n="" then

n=100

end if%>
<%

if owen1<>"" and owen2<>"" then

sql="select * from NEWS where
BigClassName='"& owen1 &"' and
SmallClassName='"& owen2 &"' order by id desc"

set rs=conn.execute(sql)

do while not rs.eof

%>

javastr=javastr+"<tr><td height=\"24\"
style=\"BORDER-bottom: #999999 1px dotted\">"

javastr=javastr+"◎ <span
style=\"font-size:9pt;line-height:15pt\"><% if
rs("imagenum")<>"0" then response.write "<img
src='images/news.gif' border=0 alt='图片新闻'>" end if
%><a href=\"onews.asp?id=<%=rs("id")%>\"
title=\"<%=rs("title")%>\"
target=\"_blank\"><%=left(rs("title"),12)%></a></span>
<font color=\"#999999\"
>[<%=rs("infotime")%>]</font> <font
color=\"#999999\" >(阅读<font color=\"#FF0000\"
><%=rs("hits")%></font>次)</font>"

javastr=javastr+"</td></tr>"

<%n=n-1

if n<1 then exit do

rs.movenext

loop

%>

javastr=javastr+"</table>"

<%

rs.close

set rs=nothing

%>

document.write (javastr)
<%

ElseIf owen2<> "" then

sql="select * from NEWS where
SmallClassName='"& owen2 &"' order by id desc"

set rs=conn.execute(sql)

do while not rs.eof

%>

javastr=javastr+"<tr><td height=\"24\"
style=\"BORDER-bottom: #999999 1px dotted\">"

javastr=javastr+"◎ <span
style=\"font-size:9pt;line-height:15pt\"><% if
rs("imagenum")<>"0" then response.write "<img
src='images/news.gif' border=0 alt='图片新闻'>" end if
%><a href=\"onews.asp?id=<%=rs("id")%>\"
title=\"<%=rs("title")%>\"
target=\"_blank\"><%=left(rs("title"),12)%></a></span>
<font color=\"#999999\"
>[<%=rs("infotime")%>]</font> <font
color=\"#999999\" >(阅读<font color=\"#FF0000\"
><%=rs("hits")%></font>次)</font>"

javastr=javastr+"</td></tr>"

<%n=n-1

if n<1 then exit do

rs.movenext

loop

%>

javastr=javastr+"</table>"

<%

rs.close

set rs=nothing

%>

document.write (javastr)
<%

ElseIf owen1<>"" then

sql="select * from NEWS where
BigClassName='"& owen1 &"' order by id desc"

set rs=conn.execute(sql)

do while not rs.eof

%>

javastr=javastr+"<tr><td height=\"24\"
style=\"BORDER-bottom: #999999 1px dotted\">"

javastr=javastr+"◎ <span
style=\"font-size:9pt;line-height:15pt\"><% if
rs("imagenum")<>"0" then response.write "<img
src='images/news.gif' border=0 alt='图片新闻'>" end if
%><a href=\"onews.asp?id=<%=rs("id")%>\"
title=\"<%=rs("title")%>\"
target=\"_blank\"><%=rs("title")%></a></span>
<font color=\"#999999\"
>[<%=rs("infotime")%>]</font> <font
color=\"#999999\" >(阅读<font color=\"#FF0000\"
><%=rs("hits")%></font>次)</font>"

javastr=javastr+"</td></tr>"

<%n=n-1

if n<1 then exit do

rs.movenext

loop

%>

javastr=javastr+"</table>"

<%

rs.close

set rs=nothing

%>

document.write (javastr)

<% End If %>
<%

if owen1= "" and owen2= "" then

sql="select * from NEWS order by id desc"

set rs=conn.execute(sql)

do while not rs.eof

%>

javastr=javastr+"<tr><td height=\"24\"
style=\"BORDER-bottom: #999999 1px dotted\">"

javastr=javastr+"◎ <span
style=\"font-size:9pt;line-height:15pt\"><% if
rs("imagenum")<>"0" then response.write "<img
src='images/news.gif' border=0 alt='图片新闻'>" end if
%><a href=\"onews.asp?id=<%=rs("id")%>\"
title=\"<%=rs("title")%>\"
target=\"_blank\"><%=left(rs("title"),12)%></a></span>
<font color=\"#999999\"
>[<%=rs("infotime")%>]</font> <font
color=\"#999999\" >(阅读<font color=\"#FF0000\"
><%=rs("hits")%></font>次)</font>"

javastr=javastr+"</td></tr>"

<%n=n-1

if n<1 then exit do

rs.movenext

loop

%>

javastr=javastr+"</table>"

<%rs.close

set rs=nothing

conn.close

set conn=nothing%>

document.write (javastr)

<%end if%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: