深圳开发公司网站建设,wordpress密码可见,吉林省建设厅网站专家,深圳市城乡建设部网站首页因为项目需要#xff0c;所以去找了下轮显图片的代码。网上很多#xff0c;简单的修改了下#xff0c;恩可以显示图片。但是问题来了#xff0c;当没有数据的时候会出现页面显示出现问题。后来才发现是我对数据库有没有数据进行判断的时候出现了问题。居然连最基本的顺序执…因为项目需要所以去找了下轮显图片的代码。网上很多简单的修改了下恩可以显示图片。但是问题来了当没有数据的时候会出现页面显示出现问题。后来才发现是我对数据库有没有数据进行判断的时候出现了问题。居然连最基本的顺序执行都给忘记了。所以后来只要改动下代码的位置就OK了。贴出来代码积累点经验。学习asp还是有很长的路要走的。
代码段1. jsflash搞定。 % pathlevel ../ % !-- #include file ../data/conn.asp -- % ----------------- 数据库连接 幻灯片新闻sqlselect top 5 * from [图表专区] where 属于5 and 类别1 order by 编号 descset rsserver.createobject(adodb.recordset)rs.open sql,cn,1,1if not rs.eof then -------------------读取数据库内容-----------------下面是对读取的内容进行处理k1Num_totalrs.recordcountfor i1 to 5if iNum_total then exit forif i1 thenimgUrl11rs(图片) if len(rs(标题))18 then imgtext11 left(rs(标题),18)... else imgtext11rs(标题) end ifimgLink11rs(图片)end ifif i2 thenimgUrl22rs(图片) if len(rs(标题))18 then imgtext22 left(rs(标题),18)... else imgtext22rs(标题) end ifimgLink22rs(图片)end ifif i3 thenimgUrl33rs(图片) if len(rs(标题))18 then imgtext33 left(rs(标题),18)... else imgtext33rs(标题) end ifimgLink33rs(图片)end ifif i4 thenimgUrl44rs(图片) if len(rs(标题))18 then imgtext44 left(rs(标题),18)... else imgtext44rs(标题) end ifimgLink44rs(图片)end ifif i5 thenimgUrl55rs(图片) if len(rs(标题))18 then imgtext55 left(rs(标题),18)... else imgtext55rs(标题) end ifimgLink55rs(图片)end ifrs.movenextkk1next%----------------有数据的时候调用flash显示图片a target_self hrefjavascript:goUrl() span classf14b script typetext/javascriptimgUrl1%imgUrl11%;imgtext1%imgtext11%imgLink1escape(%imgLink11%);imgUrl2%imgUrl22%;imgtext2%imgtext22%imgLink2escape(%imgLink22%);imgUrl3%imgUrl33%;imgtext3%imgtext33%imgLink3escape(%imgLink33%);imgUrl4%imgUrl44%;imgtext4%imgtext44%imgLink4escape(%imgLink44%);imgUrl5%imgUrl55%;imgtext5%imgtext55%imgLink5escape(%imgLink55%);var focus_width246 var focus_height142 var text_height15 var swf_height focus_heighttext_height %if Num_total1 then% var picsimgUrl1 var linksimgLink1 var textsimgtext1 %elseif Num_total2 then% var picsimgUrl1|imgUrl2 var linksimgLink1|imgLink2 var textsimgtext1|imgtext2 %elseif Num_total3 then% var picsimgUrl1|imgUrl2|imgUrl3 var linksimgLink1|imgLink2|imgLink3 var textsimgtext1|imgtext2|imgtext3 %elseif Num_total4 then% var picsimgUrl1|imgUrl2|imgUrl3|imgUrl4 var linksimgLink1|imgLink2|imgLink3|imgLink4 var textsimgtext1|imgtext2|imgtext3|imgtext4 %elseif Num_total5 then% var picsimgUrl1|imgUrl2|imgUrl3|imgUrl4|imgUrl5 var linksimgLink1|imgLink2|imgLink3|imgLink4|imgLink5 var textsimgtext1|imgtext2|imgtext3|imgtext4|imgtext5 %end if% document.write( object classid clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version6,0,0,0 width focus_width height swf_height ); document.write( param name allowScriptAccess value sameDomain param name movie value 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 picspicslinkslinkstextstextsborderwidthfocus_widthborderheightfocus_heighttextheighttext_height ); document.write( embed src pixviewer.swf wmode opaque FlashVars picspicslinkslinkstextstextsborderwidthfocus_widthborderheightfocus_heighttextheighttext_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/aspan idfocustext classf14b /span----------------------没有数据直接输出 %else response.Write 暂时没有数据end if% 把上面的文件保存在一个文件show.asp内在需要的地方直接调用就可以了。。
这样就不会出现页面显示混乱的问题了。。。需要一个显示图片的flash。
下面贴一个jsdiv 显示的。 % pathlevel ../ % !-- #include file ../data/conn.asp -- Script Language JavaScript !-- function SlidePic(ID) ... {this.IDID; this.Width0;this.Height0; this.TimeOut5000;this.Effect23;this.TitleLen0; this.PicNum-1; this.Imgnull; this.Urlnull; this.Titlenull; this.AllPicnew Array(); this.AddAddSlidePic; this.ShowShowSlidePic; this.LoopShowLoopShowSlidePic;} function NewSlide() ... {this.ImgUrl; this.LinkUrl; this.Title;} function AddSlidePic(SP) ... {this.AllPic[this.AllPic.length] SP;} function ShowSlidePic() ... { if(this.AllPic[0] null) return false; document.write(div aligncentera idUrl this.ID href target_blankimg idImg this.ID stylewidth: this.Width ; height: this.Height ; filter: revealTrans(duration2,transition23); srcjavascript:null border0/a); if(this.TitleLen ! 0) document.write(brDiv idTitle this.ID /Div/div); this.Img document.getElementById(Img this.ID); this.Url document.getElementById(Url this.ID); this.Title document.getElementById(Title this.ID); this.LoopShow(); } function LoopShowSlidePic() ... { if(this.PicNumthis.AllPic.length-1) this.PicNum ; else this.PicNum0; this.Img.filters.revealTrans.Transitionthis.Effect; this.Img.filters.revealTrans.apply(); this.Img.srcthis.AllPic[this.PicNum].ImgUrl; this.Img.filters.revealTrans.play(); this.Url.hrefthis.AllPic[this.PicNum].LinkUrl; if(this.Title) this.Title.innerHTMLa hrefthis.AllPic[this.PicNum].LinkUrl this.AllPic[this.PicNum].Title/a; this.Img.timersetTimeout(this.ID.LoopShow(),this.TimeOut); } var SlidePic new SlidePic( SlidePic ); SlidePic.Width 150 ; // 图片宽度 SlidePic.Height 120 ; // 图片高度 SlidePic.TimeOut 5000 ; // 延迟时间 SlidePic.Effect 23 ; SlidePic.TitleLen 1 ; % 幻灯片新闻 sqlselect top 3 * from 图表专区 where 属于16 and 类别2 order by 编号 desc //数据库字段 set rsserver.createobject(adodb.recordset) rs.open sql,cn,1,1 if not rs.eof then k1 Num_totalrs.recordcount for i1 to Num_total % var NewItem new NewSlide(); NewItem.ImgUrl % rs( 图片 ) % ; //图片地址 NewItem.LinkUrl % rs( 图片 ) % ; //链接地址 NewItem.Title span % rs( 标题 ) %/ span ; //新闻标题 SlidePic.Add(NewItem); % rs.movenext kk1 loop next else response.write 暂无图片新闻 end if % SlidePic.Show(); // -- / Script 这个也是保存为一个文件在需要的时候直接调用就OK啦。。。