Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[疑问] ss首页幻灯不会动的原因?

[复制链接]
zmlf 发表于 2009-11-5 20:48:13 | 显示全部楼层 |阅读模式
本帖最后由 zmlf 于 2009-11-5 21:58 编辑

高手请看http://www.xcxm.net/ss/我把原来的header里的js调用都去掉试过,好像不存在js冲突的可能
我排查了好久就是找不出原因
高手帮我看看

附上js代码

  1. // 焦点轮换图片
  2. function addLoadEvent(func){
  3.         var oldonload = window.onload;
  4.         if (typeof window.onload != 'function') {
  5.                 window.onload = func;
  6.         } else {
  7.                 window.onload = function(){
  8.                         oldonload();
  9.                         func();
  10.                 }
  11.         }
  12. }

  13. function moveElement(elementID,final_x,final_y,interval) {
  14.   if (!document.getElementById) return false;
  15.   if (!document.getElementById(elementID)) return false;
  16.   var elem = document.getElementById(elementID);
  17.   if (elem.movement) {
  18.     clearTimeout(elem.movement);
  19.   }
  20.   if (!elem.style.left) {
  21.     elem.style.left = "0px";
  22.   }
  23.   if (!elem.style.top) {
  24.     elem.style.top = "0px";
  25.   }
  26.   var xpos = parseInt(elem.style.left);
  27.   var ypos = parseInt(elem.style.top);
  28.   if (xpos == final_x && ypos == final_y) {
  29.                 return true;
  30.   }
  31.   if (xpos < final_x) {
  32.     var dist = Math.ceil((final_x - xpos)/10);
  33.     xpos = xpos + dist;
  34.   }
  35.   if (xpos > final_x) {
  36.     var dist = Math.ceil((xpos - final_x)/10);
  37.     xpos = xpos - dist;
  38.   }
  39.   if (ypos < final_y) {
  40.     var dist = Math.ceil((final_y - ypos)/10);
  41.     ypos = ypos + dist;
  42.   }
  43.   if (ypos > final_y) {
  44.     var dist = Math.ceil((ypos - final_y)/10);
  45.     ypos = ypos - dist;
  46.   }
  47.   elem.style.left = xpos + "px";
  48.   elem.style.top = ypos + "px";
  49.   var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  50.   elem.movement = setTimeout(repeat,interval);
  51. }

  52. function classNormal(focus_turn_btn,focus_turn_tx){
  53.         var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
  54.         var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
  55.         for(var i=0; i<focusBtnList.length; i++) {
  56.                 focusBtnList[i].className='normal';
  57.                 focusTxList[i].className='normal';
  58.         }
  59. }

  60. function classCurrent(focus_turn_btn,focus_turn_tx,n){
  61.         var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
  62.         var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
  63.         focusBtnList[n].className='current';
  64.         focusTxList[n].className='current';
  65. }

  66. function newsfocusChange() {
  67.         if(!$('news_focus_turn')||!$('news_focus_turn_btn')) return;
  68.         $('news_focus_turn').onmouseover = function(){atuokey = true};
  69.         $('news_focus_turn').onmouseout = function(){atuokey = false};
  70.         var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
  71.         if(!focusBtnList||focusBtnList.length==0) return;
  72.         var listLength = focusBtnList.length;
  73.                 focusBtnList[0].onmouseover = function() {
  74.                         moveElement('news_focus_turn_picList',0,0,5);
  75.                         classNormal('news_focus_turn_btn','news_focus_turn_tx');
  76.                         classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
  77.                 }
  78.         if (listLength>=2) {
  79.                 focusBtnList[1].onmouseover = function() {
  80.                         moveElement('news_focus_turn_picList',-341,0,5);
  81.                         classNormal('news_focus_turn_btn','news_focus_turn_tx');
  82.                         classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
  83.                 }
  84.         }
  85.         if (listLength>=3) {
  86.                 focusBtnList[2].onmouseover = function() {
  87.                         moveElement('news_focus_turn_picList',-682,0,5);
  88.                         classNormal('news_focus_turn_btn','news_focus_turn_tx');
  89.                         classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
  90.                 }
  91.         }
  92.         if (listLength>=4) {
  93.                 focusBtnList[3].onmouseover = function() {
  94.                         moveElement('news_focus_turn_picList',-1023,0,5);
  95.                         classNormal('news_focus_turn_btn','news_focus_turn_tx');
  96.                         classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
  97.                 }
  98.         }
  99. }

  100. setInterval('newsautoFocusChange()', 5000);
  101. var atuokey = false;
  102. function newsautoFocusChange() {
  103.         if(!$('news_focus_turn_btn')) return;
  104.         if(atuokey) return;
  105.         var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
  106.         var listLength = focusBtnList.length;
  107.         for(var i=0; i<focusBtnList.length; i++) {
  108.                 if (focusBtnList[i].className == 'current') var currentNum = i;
  109.         }
  110.         if (currentNum==0&&listLength!=1 ){
  111.                 moveElement('news_focus_turn_picList',-341,0,5);
  112.                 classNormal('news_focus_turn_btn','news_focus_turn_tx');
  113.                 classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
  114.         }
  115.         if (currentNum==1&&listLength!=2 ){
  116.                 moveElement('news_focus_turn_picList',-682,0,5);
  117.                 classNormal('news_focus_turn_btn','news_focus_turn_tx');
  118.                 classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
  119.         }
  120.         if (currentNum==2&&listLength!=3 ){
  121.                 moveElement('news_focus_turn_picList',-1023,0,5);
  122.                 classNormal('news_focus_turn_btn','news_focus_turn_tx');
  123.                 classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
  124.         }
  125.         if (currentNum==3){
  126.                 moveElement('news_focus_turn_picList',0,0,5);
  127.                 classNormal('news_focus_turn_btn','news_focus_turn_tx');
  128.                 classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
  129.         }
  130.         if (currentNum==1&&listLength==2 ){
  131.                 moveElement('news_focus_turn_picList',0,0,5);
  132.                 classNormal('news_focus_turn_btn','news_focus_turn_tx');
  133.                 classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
  134.         }
  135.         if (currentNum==2&&listLength==3 ){
  136.                 moveElement('news_focus_turn_picList',0,0,5);
  137.                 classNormal('news_focus_turn_btn','news_focus_turn_tx');
  138.                 classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
  139.         }
  140. }

  141. function indexfocusChange() {
  142.         if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
  143.         $('index_focus_turn').onmouseover = function(){atuokey = true};
  144.         $('index_focus_turn').onmouseout = function(){atuokey = false};
  145.         var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
  146.         if(!focusBtnList||focusBtnList.length==0) return;
  147.         var listLength = focusBtnList.length;
  148.                 focusBtnList[0].onmouseover = function() {
  149.                         moveElement('index_focus_turn_picList',0,0,5);
  150.                         classNormal('index_focus_turn_btn','index_focus_turn_tx');
  151.                         classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
  152.                 }
  153.         if (listLength>=2) {
  154.                 focusBtnList[1].onmouseover = function() {
  155.                         moveElement('index_focus_turn_picList',0,-295,5);
  156.                         classNormal('index_focus_turn_btn','index_focus_turn_tx');
  157.                         classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
  158.                 }
  159.         }
  160.         if (listLength>=3) {
  161.                 focusBtnList[2].onmouseover = function() {
  162.                         moveElement('index_focus_turn_picList',0,-590,5);
  163.                         classNormal('index_focus_turn_btn','index_focus_turn_tx');
  164.                         classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
  165.                 }
  166.         }
  167.         if (listLength>=4) {
  168.                 focusBtnList[3].onmouseover = function() {
  169.                         moveElement('index_focus_turn_picList',0,-885,5);
  170.                         classNormal('index_focus_turn_btn','index_focus_turn_tx');
  171.                         classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
  172.                 }
  173.         }
  174. }

  175. setInterval('indexautoFocusChange()',5000);
  176. var atuokey = false;
  177. function indexautoFocusChange() {
  178.         if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
  179.         if(atuokey) return;
  180.         var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
  181.         var listLength = focusBtnList.length;
  182.         for(var i=0; i<listLength; i++) {
  183.                 if (focusBtnList[i].className == 'current') var currentNum = i;
  184.         }
  185.         if (currentNum==0&&listLength!=1 ){
  186.                 moveElement('index_focus_turn_picList',0,-295,5);
  187.                 classNormal('index_focus_turn_btn','index_focus_turn_tx');
  188.                 classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
  189.         }
  190.         if (currentNum==1&&listLength!=2 ){
  191.                 moveElement('index_focus_turn_picList',0,-590,5);
  192.                 classNormal('index_focus_turn_btn','index_focus_turn_tx');
  193.                 classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
  194.         }
  195.         if (currentNum==2&&listLength!=3 ){
  196.                 moveElement('index_focus_turn_picList',0,-885,5);
  197.                 classNormal('index_focus_turn_btn','index_focus_turn_tx');
  198.                 classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
  199.         }
  200.         if (currentNum==3 ){
  201.                 moveElement('index_focus_turn_picList',0,0,5);
  202.                 classNormal('index_focus_turn_btn','index_focus_turn_tx');
  203.                 classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
  204.         }
  205.         if (currentNum==1&&listLength==2 ){
  206.                 moveElement('index_focus_turn_picList',0,0,5);
  207.                 classNormal('index_focus_turn_btn','index_focus_turn_tx');
  208.                 classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
  209.         }
  210.         if (currentNum==2&&listLength==3 ){
  211.                 moveElement('index_focus_turn_picList',0,0,5);
  212.                 classNormal('index_focus_turn_btn','index_focus_turn_tx');
  213.                 classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
  214.         }
  215. }
  216. addLoadEvent(newsfocusChange);
  217. addLoadEvent(indexfocusChange);
  218. addLoadEvent(nav);
  219. }
复制代码
相应css代码:
  1.         /* News Focus Turn style start */
  2. #news_focus_turn {
  3.         height:464px;
  4.         overflow:hidden;
  5.         margin-bottom:6px;
  6.         border:1px solid #DEDEDE;
  7.         background-color: #333333;
  8. }
  9.         #news_focus_turn_pic { position:relative; width:341px; height:280px; overflow:hidden; }
  10.                 #news_focus_turn_pic div { position:absolute; width:1600px; }
  11.                 #news_focus_turn_pic div li { float:left; }
  12.                 #news_focus_turn_pic div li img { float:left;width: expression(341 / this.width * this.height > 280 ? 341 : this.width * 280 / this.height);  max-width: 341px; min-width: 341px; }
  13.         #news_focus_turn_btn { height:87px; overflow:hidden; margin:4px auto 0; padding-left:2px; }
  14.                 #news_focus_turn_btn li { display:inline; float:left; margin:0 0 0 4px; padding-top:3px; cursor:pointer; }
  15.                 #news_focus_turn_btn img { width:75px; height:73px; border:2px solid #FFF; filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; }
  16.                 #news_focus_turn_btn .current {}
  17.                 #news_focus_turn_btn .current img {
  18.         border-color:#FFFFFF;
  19.         filter:alpha(opacity=100);
  20.         -moz-opacity:1.0;
  21.         opacity:1.0;
  22. }
  23.         #news_focus_turn_tx { position:relative; width:94%; margin:0 auto; padding:0px 3px; background:url(../images/dashed_bg.gif) repeat-x center top; }
  24.                 #news_focus_turn_tx h3 { padding-bottom:3px; font-size:14px; }
  25.                 #news_focus_turn_tx h3 a { color:#CCCCCC}
  26.                 #news_focus_turn_tx strong {
  27.         position:absolute;
  28.         top:14px;
  29.         right:6px;
  30.         color:#CCCCCC;
  31. }
  32.                 #news_focus_turn_tx p { height:80px; overflow:hidden; line-height:1.3em; }
  33.                 #news_focus_turn_tx p a {
  34.         color:#CCCCCC;
  35.         text-decoration:underline;
  36. }
  37.                 #news_focus_turn_tx .normal { display:none; }
  38.         /* News Focus Turn style end */
复制代码
及页面div代码
  1. <div id="news_focus_turn">
  2.                         <!--{if !empty( $_SBLOCK['picnews'])}-->
  3.                                 <div id="news_focus_turn_pic">
  4.                                 <div id="news_focus_turn_picList" style="left:0; top:0;">
  5.                                         <ul>
  6.                                                 <!--{loop $_SBLOCK['picnews'] $pkey $pvalue}-->
  7.                                                 <li><a href="#action/viewnews/itemid/$pvalue[itemid]#"><img src="$pvalue['a_filepath']" alt="$pvalue[subject]" /></a></li>
  8.                                                 <!--{/loop}-->
  9.                                         </ul>
  10.                                 </div>
  11.                                 </div>
  12.                                 <div id="news_focus_turn_btn">
  13.                                         <ul>
  14.                                                 <!--{eval $i = 0}-->
  15.                                                 <!--{loop $_SBLOCK['picnews'] $key $value}-->
  16.                                                 <!--{eval $current = ($i == 0 ? 'current' : 'normal');}-->
  17.                                                 <li class="$current"><img src="$value[a_thumbpath]" alt="$value[subject]" /></li>
  18.                                                 <!--{eval $i++}-->
  19.                                                 <!--{/loop}-->
  20.                                         </ul>
  21.                                 </div>
  22.                                 <div id="news_focus_turn_tx">
  23.                                         <ul>
  24.                                                 <!--{eval $i = 0}-->
  25.                                                 <!--{loop $_SBLOCK['picnews'] $bkey $bvalue}-->
  26.                                                 <!--{eval $current = ($i == 0 ? 'current' : 'normal');}-->
  27.                                                 <li class="$current"><h3><a href="$value[url]" >$bvalue[subject]</a></h3><strong>[#date('m.d', $bvalue['dateline'])#]</strong>
  28.                                                 <p>$bvalue[message]<a href="$bvalue[url]">阅读全文</a></p>
  29.                                                 </li>
  30.                                                 <!--{eval $i++}-->
  31.                                                 <!--{/loop}-->
  32.                                         </ul>
  33.                                 </div>
  34.                         <!--{/if}-->
  35.                         </div><!--news_focus_turn end-->
复制代码
回复

使用道具 举报

 楼主| zmlf 发表于 2009-11-5 20:48:55 | 显示全部楼层
急急跪求
RMB也可
回复

使用道具 举报

Gnagno 发表于 2009-11-5 21:14:25 | 显示全部楼层
我猜是代码不完整
回复

使用道具 举报

benba 发表于 2009-11-5 21:18:04 | 显示全部楼层
我猜都不想猜...这么多代码.看着头疼.....
回复

使用道具 举报

benba 发表于 2009-11-5 21:22:14 | 显示全部楼层
把第JS里最后一行的"}" 删了试试看吧.

syntax error
回复

使用道具 举报

 楼主| zmlf 发表于 2009-11-5 21:34:20 | 显示全部楼层
试过了没有用呢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-9-16 03:17 , Processed in 0.115443 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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