找回密码
 快速注册

QQ登录

只需一步,快速开始

查看: 3806|回复: 0

用js制作的网页图片轮播效果代码

[复制链接]
眼镜蛇 发表于 2010-10-26 22:42:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?快速注册

×
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  5. <title>js图片轮播效果</title>
  6. </head>

  7. <body><SCRIPT>
  8. var widths=645;
  9. var heights=433;
  10. var counts=3;
  11. img1=new Image ();img1.src='http://www.wenliren.com/topic/music/member/01.jpg';
  12. img2=new Image ();img2.src='http://www.wenliren.com/topic/music/member/02.jpg';
  13. img3=new Image ();img3.src='http://www.wenliren.com/topic/music/member/03.jpg';
  14. url1=new Image ();url1.src='http://www.wenliren.com';
  15. url2=new Image ();url2.src='http://www.wenliren.com';
  16. url3=new Image ();url3.src='http://www.wenliren.com';
  17. var nn=1;
  18. var key=0;
  19. function change_img()
  20. {if(key==0){key=1;}
  21. else if(document.all)
  22. {document.getElementById("pic").filters[0].Apply();document.getElementById("pic").filters[0].Play(duration=2);}
  23. eval('document.getElementById("pic").src=img'+nn+'.src');
  24. eval('document.getElementById("url").href=url'+nn+'.src');
  25. for (var i=1;i<=counts;i++){document.getElementById("xxjdjj"+i).className='axx';}
  26. document.getElementById("xxjdjj"+nn).className='bxx';
  27. nn++;if(nn>counts){nn=1;}
  28. tt=setTimeout('change_img()',3000);}
  29. function changeimg(n){nn=n;window.clearInterval(tt);change_img();}
  30. document.write('<style>');
  31. document.write('.axx{padding:1px 7px;border-left:#cccccc 1px solid;}');
  32. document.write('a.axx:link,a.axx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#666;}');
  33. document.write('a.axx:active,a.axx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#999;}');
  34. document.write('.bxx{padding:1px 7px;border-left:#cccccc 1px solid;}');
  35. document.write('a.bxx:link,a.bxx:visited{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
  36. document.write('a.bxx:active,a.bxx:hover{text-decoration:none;color:#fff;line-height:12px;font:9px sans-serif;background-color:#D34600;}');
  37. document.write('</style>');
  38. document.write('<div style="width:'+widths+'px;height:'+heights+'px;overflow:hidden;text-overflow:clip;">');
  39. document.write('<div><a id="url"><img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /></a></div>');
  40. document.write('<div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;">');
  41. for(var i=1;i<counts+1;i++){document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self">'+i+'</a>');}
  42. document.write('</div></div>');
  43. change_img();
  44. </SCRIPT>

  45. </body>
  46. </html>

复制代码

您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

快速回复 返回顶部 返回列表