找回密码
 入学

QQ登录

只需一步,快速开始

查看: 1620|回复: 0

无按钮图片轮播切换

[复制链接]
发表于 2014-1-13 15:03:22 | 显示全部楼层 |阅读模式

主文件cpfocus.htm
  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>无按钮图片切换</title>
  6. <style type="text/css">
  7. #cpfocus{width:380px;height:504px;margin:0 auto;}
  8. #cpfocus div{position:absolute;width:380px;height:504px;overflow:hidden;}
  9. #cpfocus img{width:380px;height:504px;}
  10. #cpfocus #cpfocus_img{display:none;}
  11. </style>
  12. </head>
  13. <body>
  14.         <div id="cpfocus">
  15.                 <div id="cpfocus_bg"></div>
  16.                 <div id="cpfocus_show"></div>
  17.                 <div id="cpfocus_img">
  18.                         <div name="cpfocus_img" id="cpfocus_1">plus/cpfocus/01.jpg|#|美女1号</div>
  19.                         <div name="cpfocus_img" id="cpfocus_2">plus/cpfocus/02.jpg|#|美女2号</div>
  20.                 </div>
  21.                 <script type="text/javascript" src="plus/cpfocus/cpfocus.js"></script>
  22.         </div><!--focus end-->
  23. </body>
  24. </html>
复制代码
基本文件cpfocus.js
  1. var cpfocus_id = 1;
  2. var cpfocus_time = 0;
  3. var cpfocus_bg = "";
  4. var cpfocus_begin = true;
  5. var cpfocus_interval;
  6. var cpfocus_count;
  7. var cpfocus_url = "";
  8. var cpfocus_title = "";
  9. if(navigator.appName == "Microsoft Internet Explorer")
  10. {
  11.         cpfocus_count = document.getElementById("cpfocus_img").childNodes.length;
  12. }else{
  13.         cpfocus_count = document.getElementsByName("cpfocus_img").length;
  14. }
  15. function func_cpfocus()
  16. {
  17.         if(cpfocus_id > cpfocus_count) cpfocus_id = 1;
  18.         if(!cpfocus_begin) clearInterval(cpfocus_interval);
  19.         cpfocus_interval = setInterval("cpfocus_show(" + cpfocus_id + ")",50);
  20. }
  21. function cpfocus_show(id)
  22. {
  23.         if(cpfocus_time < 20 && cpfocus_bg != "")
  24.         {
  25.                 var v = 100 / 20;
  26.                 if(navigator.appName=="Microsoft Internet Explorer")
  27.                 {
  28.                         document.getElementById("cpfocus_show").style.filter = "Alpha(Opacity=" + (v * cpfocus_time) + ")";
  29.                 }else{
  30.                         document.getElementById("cpfocus_show").style.opacity = v * cpfocus_time / 100;
  31.                 }
  32.                 cpfocus_time ++;
  33.         }else if(cpfocus_count > 0){
  34.                 if(!cpfocus_begin)
  35.                 {
  36.                         document.getElementById("cpfocus_bg").innerHTML = "<img src='" + cpfocus_bg + "' />";
  37.                         cpfocus_time = 0;
  38.                         clearInterval(cpfocus_interval);
  39.                 }
  40.                 var val = document.getElementById("cpfocus_" + cpfocus_id).innerHTML;
  41.                 var arr = val.split("|");
  42.                 if(navigator.appName=="Microsoft Internet Explorer")
  43.                 {
  44.                         document.getElementById("cpfocus_show").style.filter = "Alpha(Opacity=0)";
  45.                 }else{
  46.                         document.getElementById("cpfocus_show").style.opacity = 0;
  47.                 }
  48.                 document.getElementById("cpfocus_show").innerHTML = "<a href='" + cpfocus_url + "' target='_blank' title='" + cpfocus_title + "'><img src='" + arr[0] + "' /></a>";
  49.                 cpfocus_url = arr[1];
  50.                 cpfocus_title = arr[2];
  51.                 if(cpfocus_count > 1) cpfocus_id ++;
  52.                 if(!cpfocus_begin) cpfocus_interval = setInterval("func_cpfocus()",3000); else cpfocus_begin = false;
  53.                 cpfocus_bg = arr[0];
  54.         }
  55. }
  56. func_cpfocus();
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?入学

×
您需要登录后才可以回帖 登录 | 入学

本版积分规则

QQ|Archiver|手机版|小黑屋|校园天空成立于2004年2月24日 ( 陕ICP备08000078号-8 )

GMT+8, 2025-5-11 00:05 , Processed in 0.111905 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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