带链接幻灯片显示图片JS代码


(文章ID:175)|(编辑:Isen)|(点击次数:2324)|(添加时间:2008-04-18 15:07:21)|(添加IP:218.88.227.47)

    〈DIV align=center〉

    〈TABLE style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=241 border=0〉

    〈TBODY〉

    〈TR〉

    //一下三行就是三张图片,修改即可

    〈TD id=Source〉〈A href="imgshow.asp" target=_blank〉〈IMG height=180 src="xxx.gif" width=241 border=0〉〈/A〉 〈/TD〉

    〈TD id=Source〉〈A href="imgshow.asp" target=_blank〉〈IMG height=180 src="xxxjpg" width=241 border=0〉〈/A〉 〈/TD〉

    〈TD id=Source〉〈A href="imgshow.asp" target=_blank〉〈IMG height=180 src="images/xxx.gif" width=241 border=0〉〈/A〉 〈/TD〉

    〈/TR〉

    〈/TBODY〉

    〈/TABLE〉

    〈SCRIPT language=javascript〉

     var pics='';

     var links='';

     var texts='';

     var sources = document.all["Source"];

     for(var i=0;i〈sources.length;i++)

     {

     var sourceStr = sources[i].innerHTML;

     if(sourceStr.indexOf("=")〉=0)

     {

     if(links=='')

     links = sourceStr.substring(sourceStr.indexOf("=")+2,sourceStr.indexOf("target")-2);

     else

     links = links + '|' +sourceStr.substring(sourceStr.indexOf("=")+2,sourceStr.indexOf("target")-2);

     if(pics=='')

     pics = sourceStr.substring(sourceStr.indexOf("src=")+5,sourceStr.indexOf("width=241")-2);

     else

     pics = pics + '|' +sourceStr.substring(sourceStr.indexOf("src=")+5,sourceStr.indexOf("width=241")-2);

     if(texts=='')

     texts = sourceStr.substring(sourceStr.indexOf("alt=")+4,sourceStr.indexOf("src="));

     else

     texts = texts + '|'+sourceStr.substring(sourceStr.indexOf("alt=")+4,sourceStr.indexOf("src="));

     }

    

     }

     var picsarray= pics.split("|");

     var linksarray=links.split("|");

     var textsarray=texts.split("|");

    

     var cur = 0;

     var start = 0;

    

     function showImageNews()

     {

     if (picsarray.length == 0)

     return;

    

     if (cur 〉= picsarray.length)

     cur = 0;

    

    

     if (start != 0)

     {

     try

     {

     ImageNewsImg.filters.item(0).apply();

     ImageNewsImg.filters.item(0).transition = 23;//样式

     ImageNewsImg.filters.item(0).play(1); //速度

     }

     catch (e)

     {

    

     }

     }

    

     start = 1;

    

     ImageNewsImg.innerHTML = "〈a href='" + linksarray[cur] + "' target='_blank'〉〈img src='" + picsarray[cur] + "' width=265 height=196 border='0'〉〈/a〉";

    

     cur += 1;

    

     if (picsarray.length 〉 1)

     setTimeout("showImageNews();",5000);

     }

    〈/SCRIPT〉

    〈TABLE cellSpacing=0 cellPadding=0 width="95%" border=0〉

    〈TBODY〉

    〈TR〉

    〈TD id=ImageNewsImg

    style="FILTER: revealTrans()"〉〈/TD〉〈/TR〉〈/TBODY〉〈/TABLE〉

    〈SCRIPT〉

     showImageNews();

    〈/SCRIPT〉

    〈/DIV〉

    

    如从数据库动态 加载图片范例如下:

    〈DIV align=center〉

    〈TABLE style="DISPLAY: none" cellSpacing=0 cellPadding=0 width=241 border=0〉

    〈TBODY〉

    〈TR〉

    〈%

     set ovrs=server.createobject("adodb.recordset")

     sql="select top 8 tb_image.* from tb_image WHERE type='图片新闻' ORDER BY date desc"

     ovrs.open sql,ovdb,1,1

     do while not ovrs.eof

     Response.write "〈TD id=Source〉〈A href='imgshow.asp?id="&ovrs("id")&"' target=_blank title='"&ovrs("name")&"'〉〈IMG src='"&ovrs("link")&"' width='241' height='180' border=0〉〈/A〉〈/TD〉"

     ovrs.movenext

     loop

     ovrs.close

     set ovrs=nothing

    %〉

    〈/TR〉

    〈/TBODY〉

    〈/TABLE〉

    〈SCRIPT language=javascript〉

     var pics='';

     var links='';

     var texts='';

     var sources = document.all["Source"];

     for(var i=0;i〈sources.length;i++)

     {

     var sourceStr = sources[i].innerHTML;

     if(sourceStr.indexOf("=")〉=0)

     {

     if(links=='')

     links = sourceStr.substring(sourceStr.indexOf("=")+2,sourceStr.indexOf("target")-2);

     else

     links = links + '|' +sourceStr.substring(sourceStr.indexOf("=")+2,sourceStr.indexOf("target")-2);

     if(pics=='')

     pics = sourceStr.substring(sourceStr.indexOf("src=")+5,sourceStr.indexOf("width=241")-2);

     else

     pics = pics + '|' +sourceStr.substring(sourceStr.indexOf("src=")+5,sourceStr.indexOf("width=241")-2);

     if(texts=='')

     texts = sourceStr.substring(sourceStr.indexOf("alt=")+4,sourceStr.indexOf("src="));

     else

     texts = texts + '|'+sourceStr.substring(sourceStr.indexOf("alt=")+4,sourceStr.indexOf("src="));

     }

    

     }

     var picsarray= pics.split("|");

     var linksarray=links.split("|");

     var textsarray=texts.split("|");

    

     var cur = 0;

     var start = 0;

    

     function showImageNews()

     {

     if (picsarray.length == 0)

     return;

    

     if (cur 〉= picsarray.length)

     cur = 0;

    

    

     if (start != 0)

     {

     try

     {

     ImageNewsImg.filters.item(0).apply();

     ImageNewsImg.filters.item(0).transition = 23;//样式

     ImageNewsImg.filters.item(0).play(1); //速度

     }

     catch (e)

     {

    

     }

     }

    

     start = 1;

    

     ImageNewsImg.innerHTML = "〈a href='" + linksarray[cur] + "' target='_blank'〉〈img src='" + picsarray[cur] + "' width=265 height=196 border='0'〉〈/a〉";

    

     cur += 1;

    

     if (picsarray.length 〉 1)

     setTimeout("showImageNews();",5000);

     }

    〈/SCRIPT〉

    〈TABLE cellSpacing=0 cellPadding=0 width="95%" border=0〉

    〈TBODY〉

    〈TR〉

    〈TD id=ImageNewsImg

    style="FILTER: revealTrans()"〉〈/TD〉〈/TR〉〈/TBODY〉〈/TABLE〉

    〈SCRIPT〉

     showImageNews();

    〈/SCRIPT〉

    〈/DIV〉



·上一篇:HTML JS下拉菜单代码
·下一篇:网页千色字 绿色版 V3.5.080203

粤ICP备13075271号  | Copyright © 2024 Isen Software Studio - 一森软件工作室  |  Designed by www.isennet.com  | 站长入口