<% '--------------------------------- Dim rs_maq1,sql_maq1,temp_1,temp_2,temp_3,fuck_1,fuck_2,fuck_3 Set rs_maq1 = Server.CreateObject("ADODB.Recordset") sql_maq1 = "SELECT top 10 * FROM t_news WHERE n_tid =32 and n_check = true and n_index = true ORDER BY n_date DESC"此处定义获取新闻图片、标题、地址的SQL rs_maq1.open sql_maq1,conn,1,1 %> <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT> function DoTrimProperly(str, nNamedFormat, properly, pointed, points) dim strRet strRet = Server.HTMLEncode(str) strRet = replace(strRet, vbcrlf,"") strRet = replace(strRet, vbtab,"") If (LEN(strRet) > nNamedFormat) Then strRet = LEFT(strRet, nNamedFormat) If (properly = 1) Then Dim TempArray TempArray = split(strRet, " ") Dim n strRet = "" for n = 0 to Ubound(TempArray) - 1 strRet = strRet & " " & TempArray(n) next End If If (pointed = 1) Then strRet = strRet & points End If End If DoTrimProperly = strRet End Function </SCRIPT> <%i=0 do while not rs_maq1.eof%> <% fuck_1=rs_maq1.Fields.Item("n_tid").Value&"/"&rs_maq1.Fields.Item("n_fname").Value'取值 fuck_2=rs_maq1.Fields.Item("n_mpic").Value'取值 fuck_3=DoTrimProperly((rs_maq1.Fields.Item("n_title").Value), 12, 0, 1, "...")'取值 temp_1=temp_1&"news/upload/"&fuck_2&"|"'把取到的数据连接用"|"隔开 temp_2=temp_2&"news/"&fuck_1&"|"'把取到的数据连接用"|"隔开 temp_3=temp_3&fuck_3&"|"'把取到的数据连接用"|"隔开 %> <% rs_maq1.movenext i=i+1 if i=4 then exit do loop rs_maq1.close If InStr(Right(temp_1,1),"|")>0 Then '判断取值 temp_1=Left(temp_1,Len(temp_1)-1)'把最后一个字符去掉 temp_2=Left(temp_2,Len(temp_2)-1)'把最后一个字符去掉 temp_3=Left(temp_3,Len(temp_3)-1)'把最后一个字符去掉 End if If temp_1="" Or temp_2="" Or temp_2="" Then temp_1="0.jpg" temp_2="#" temp_3="无信息" End if %> <a target=_self href="javascript:goUrl()"> <span class="f14b"> <script type="text/javascript"> imgUrl="<%=temp_1%>"; imgtext="<%=temp_2%>"; imgLink="<%=temp_3%>"; var focus_width=260 var focus_height=160 var text_height=16 var swf_height = focus_height+text_height var pics=imgUrl var links=imgtext var texts=imgLink document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6?0?0?0 width="'+ focus_width +'" height="'+ swf_height +'">'); document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="js/focus.swf"><param name="quality" value="high"> <param name="bgcolor" value="#F0F0F0">'); document.write('<param name="menu" value="false"><param name=wmode value="opaque">'); document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight=' +focus_height+'&textheight='+text_height+'">'); document.write('<embed src="js/focus.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight= '+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width ="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); </script> </span></a> 以上就是程序代码 以下是调用方法 <span id="focustext" class="f14b"></span> |