php+js实现新浪滑门效果代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#header1 {
background-color: #ffffff;
height: 200px;
width: 500px;
margin: 0px;
padding: 0px;
border: 0px;
font-family: "宋体";
font-size: 12px;
line-height:150%;
}
#menu1 {
margin: 0px;
padding: 0px;
list-style-type: none;
}
#menu1 li {
display: block;
width: 100px;
text-align: center;
float: left;
margin: 0px;
padding-top: 0.2em;
padding-right: 0px;
padding-bottom: 0.2em;
padding-left: 0px;
cursor: hand;
}
#main1 li
{
list-style-type:none;
}
.sec1 { background-color: #FFFFCC;}
.sec2 { background-color: #FEB97A;}
.block { display: block;}
.unblock { display: none;}
A:link {COLOR: #000000; TEXT-DECORATION: none}
A:visited {COLOR: #000000; TEXT-DECORATION: none}
A:active {COLOR: #000000; TEXT-DECORATION: none}
A:hover {RIGHT: 0px; COLOR: #ff0000; POSITION: relative; TOP: 1px; TEXT-DECORATION:
underline}
-->
</style>
<%
function InterceptString(txt,length)'根据中英文字符不同来截取字符
txt=trim(txt)
x = len(txt)
y = 0
if x >= 1 then
for ii = 1 to x
if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then '如果是汉字
y = y + 2
else
y = y + 1
end if
if y >= length then
txt = left(trim(txt),ii) '字符串限长
exit for
end if
next
InterceptString = txt
else
InterceptString = ""
end if
End Function
dim
conn,rs1,type1,MM_conn_STRING,rs2,type2,SQL1,SQL2,SQL3,SQL4,SQL5,rs3,rs4,rs5,type3,type4,t
ype5
MM_conn_STRING = "Driver={SQL
Server};database=sanxt;server=localhost;uid=sanxt;pwd=sanxt;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
Set rs1=Server.CreateObject("ADODB.recordset")
type1="艺术资讯"
SQL1="SELECT top 7 id,caption,content,puttime FROM ccnews where classid='"&Trim(type1)&"'
order by id desc"
rs1.open SQL1,conn,1,3
%>
</head>
<body>
<script language=javascript>
function secBoard1(n)
{
for(i=0;i<menu1.childNodes.length;i++)
menu1.childNodes.className="sec1";
menu1.childNodes[n].className="sec2";
for(i=0;i<main1.childNodes.length;i++)
main1.childNodes.style.display="none";
main1.childNodes[n].style.display="block";
}
</script>
<div id="header1">
<ul id="menu1">
<li onMouseOver="secBoard1(0)" class="sec2"> 艺术资讯 </li>
<li onMouseOver="secBoard1(1)" class="sec1"> 藏家交流 </li>
<li onMouseOver="secBoard1(2)" class="sec1"> 考古发现 </li>
<li onMouseOver="secBoard1(3)" class="sec1">专题新闻</li>
<li onMouseOver="secBoard1(4)" class="sec1"> 三希堂新闻 </li>
</ul>
<!--内容显示区域-->
<ul id="main1">
<li class="block">
<%
do while not rs1.eof
%>
·<a href="../zxzx/shownews.asp?id=<%=rs1("id")%> "target=_blank><%=InterceptString(rs1
("caption")&"..........................................",48)%
></a> <%=FormatDateTime(rs1("puttime"),"2")%>
<br /><%rs1.movenext
loop
%></li><%
rs1.close
set rs1=nothing
%>
<li class="unblock"><%
Set rs2=Server.CreateObject("ADODB.recordset")
type2="藏家交流"
SQL2="SELECT top 7 id,caption,content,puttime FROM ccnews where classid='"&Trim
(type2)&"' order by id desc"
rs2.open SQL2,conn,1,3
do while not rs2.eof %>·<a href="../zxzx/shownews.asp?id=<%=rs2("id")%>"
target=_blank><%=InterceptString(rs2("caption")
&"..........................................",48)%></a> <%
=FormatDateTime(rs2("puttime"),"2")%><br />
<%rs2.movenext
loop%></li>
<%rs2.close
set rs2=nothing
%>
<li class="unblock"><%
Set rs3=Server.CreateObject("ADODB.recordset")
type3="考古发现"
SQL3="SELECT top 7 id,caption,content,puttime FROM ccnews where classid='"&Trim
(type3)&"' order by id desc"
rs3.open SQL3,conn,1,3
do while not rs3.eof %>·<a href="../zxzx/shownews.asp?id=<%=rs3("id")%>"
target=_blank><%=InterceptString(rs3("caption")
&"..........................................",48)%></a> <%
=FormatDateTime(rs3("puttime"),"2")%><br /><%rs3.movenext
loop%></li>
<%rs3.close
set rs3=nothing
%>
<li class="unblock"><%
Set rs4=Server.CreateObject("ADODB.recordset")
type4="网站公告"
SQL4="SELECT top 7 id,caption,content,puttime FROM ccnews where classid='"&Trim
(type4)&"' order by id desc"
rs4.open SQL4,conn,1,3
do while not rs4.eof %>·<a href="../zxzx/shownews.asp?id=<%=rs4("id")%>"
target=_blank><%=InterceptString(rs4("caption")
&"..........................................",48)%></a> <%
=FormatDateTime(rs4("puttime"),"2")%><br /><%rs4.movenext
loop%></li>
<%rs4.close
set rs4=nothing
%>
<li class="unblock"><%
Set rs5=Server.CreateObject("ADODB.recordset")
type5="专题新闻"
SQL5="SELECT top 7 id,caption,content,puttime FROM ccnews where classid='"&Trim
(type5)&"' order by id desc"
rs5.open SQL5,conn,1,3
do while not rs5.eof %>·<a href="../zxzx/shownews.asp?id=<%=rs5("id")%>"
target=_blank><%=InterceptString(rs5("caption")
&"..........................................",48)%></a> <%
=FormatDateTime(rs5("puttime"),"2")%><br /><%rs5.movenext
loop%></li>
<%rs5.close
set rs5=nothing
%>
</ul>
<!--内容显示区域-->
</div>
</body>
</html>