本帖最后由 zmlf 于 2009-11-5 21:58 编辑
高手请看http://www.xcxm.net/ss/我把原来的header里的js调用都去掉试过,好像不存在js冲突的可能
我排查了好久就是找不出原因
高手帮我看看
附上js代码
- // 焦点轮换图片
- function addLoadEvent(func){
- var oldonload = window.onload;
- if (typeof window.onload != 'function') {
- window.onload = func;
- } else {
- window.onload = function(){
- oldonload();
- func();
- }
- }
- }
- function moveElement(elementID,final_x,final_y,interval) {
- if (!document.getElementById) return false;
- if (!document.getElementById(elementID)) return false;
- var elem = document.getElementById(elementID);
- if (elem.movement) {
- clearTimeout(elem.movement);
- }
- if (!elem.style.left) {
- elem.style.left = "0px";
- }
- if (!elem.style.top) {
- elem.style.top = "0px";
- }
- var xpos = parseInt(elem.style.left);
- var ypos = parseInt(elem.style.top);
- if (xpos == final_x && ypos == final_y) {
- return true;
- }
- if (xpos < final_x) {
- var dist = Math.ceil((final_x - xpos)/10);
- xpos = xpos + dist;
- }
- if (xpos > final_x) {
- var dist = Math.ceil((xpos - final_x)/10);
- xpos = xpos - dist;
- }
- if (ypos < final_y) {
- var dist = Math.ceil((final_y - ypos)/10);
- ypos = ypos + dist;
- }
- if (ypos > final_y) {
- var dist = Math.ceil((ypos - final_y)/10);
- ypos = ypos - dist;
- }
- elem.style.left = xpos + "px";
- elem.style.top = ypos + "px";
- var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
- elem.movement = setTimeout(repeat,interval);
- }
- function classNormal(focus_turn_btn,focus_turn_tx){
- var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
- var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
- for(var i=0; i<focusBtnList.length; i++) {
- focusBtnList[i].className='normal';
- focusTxList[i].className='normal';
- }
- }
- function classCurrent(focus_turn_btn,focus_turn_tx,n){
- var focusBtnList = $(focus_turn_btn).getElementsByTagName('li');
- var focusTxList = $(focus_turn_tx).getElementsByTagName('li');
- focusBtnList[n].className='current';
- focusTxList[n].className='current';
- }
- function newsfocusChange() {
- if(!$('news_focus_turn')||!$('news_focus_turn_btn')) return;
- $('news_focus_turn').onmouseover = function(){atuokey = true};
- $('news_focus_turn').onmouseout = function(){atuokey = false};
- var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
- if(!focusBtnList||focusBtnList.length==0) return;
- var listLength = focusBtnList.length;
- focusBtnList[0].onmouseover = function() {
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- if (listLength>=2) {
- focusBtnList[1].onmouseover = function() {
- moveElement('news_focus_turn_picList',-341,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
- }
- }
- if (listLength>=3) {
- focusBtnList[2].onmouseover = function() {
- moveElement('news_focus_turn_picList',-682,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
- }
- }
- if (listLength>=4) {
- focusBtnList[3].onmouseover = function() {
- moveElement('news_focus_turn_picList',-1023,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
- }
- }
- }
- setInterval('newsautoFocusChange()', 5000);
- var atuokey = false;
- function newsautoFocusChange() {
- if(!$('news_focus_turn_btn')) return;
- if(atuokey) return;
- var focusBtnList = $('news_focus_turn_btn').getElementsByTagName('li');
- var listLength = focusBtnList.length;
- for(var i=0; i<focusBtnList.length; i++) {
- if (focusBtnList[i].className == 'current') var currentNum = i;
- }
- if (currentNum==0&&listLength!=1 ){
- moveElement('news_focus_turn_picList',-341,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',1)
- }
- if (currentNum==1&&listLength!=2 ){
- moveElement('news_focus_turn_picList',-682,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',2)
- }
- if (currentNum==2&&listLength!=3 ){
- moveElement('news_focus_turn_picList',-1023,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',3)
- }
- if (currentNum==3){
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- if (currentNum==1&&listLength==2 ){
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- if (currentNum==2&&listLength==3 ){
- moveElement('news_focus_turn_picList',0,0,5);
- classNormal('news_focus_turn_btn','news_focus_turn_tx');
- classCurrent('news_focus_turn_btn','news_focus_turn_tx',0)
- }
- }
- function indexfocusChange() {
- if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
- $('index_focus_turn').onmouseover = function(){atuokey = true};
- $('index_focus_turn').onmouseout = function(){atuokey = false};
- var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
- if(!focusBtnList||focusBtnList.length==0) return;
- var listLength = focusBtnList.length;
- focusBtnList[0].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- if (listLength>=2) {
- focusBtnList[1].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,-295,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
- }
- }
- if (listLength>=3) {
- focusBtnList[2].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,-590,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
- }
- }
- if (listLength>=4) {
- focusBtnList[3].onmouseover = function() {
- moveElement('index_focus_turn_picList',0,-885,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
- }
- }
- }
- setInterval('indexautoFocusChange()',5000);
- var atuokey = false;
- function indexautoFocusChange() {
- if(!$('index_focus_turn')||!$('index_focus_turn_btn')) return;
- if(atuokey) return;
- var focusBtnList = $('index_focus_turn_btn').getElementsByTagName('li');
- var listLength = focusBtnList.length;
- for(var i=0; i<listLength; i++) {
- if (focusBtnList[i].className == 'current') var currentNum = i;
- }
- if (currentNum==0&&listLength!=1 ){
- moveElement('index_focus_turn_picList',0,-295,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',1);
- }
- if (currentNum==1&&listLength!=2 ){
- moveElement('index_focus_turn_picList',0,-590,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',2);
- }
- if (currentNum==2&&listLength!=3 ){
- moveElement('index_focus_turn_picList',0,-885,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',3);
- }
- if (currentNum==3 ){
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- if (currentNum==1&&listLength==2 ){
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- if (currentNum==2&&listLength==3 ){
- moveElement('index_focus_turn_picList',0,0,5);
- classNormal('index_focus_turn_btn','index_focus_turn_tx');
- classCurrent('index_focus_turn_btn','index_focus_turn_tx',0);
- }
- }
- addLoadEvent(newsfocusChange);
- addLoadEvent(indexfocusChange);
- addLoadEvent(nav);
- }
复制代码 相应css代码:- /* News Focus Turn style start */
- #news_focus_turn {
- height:464px;
- overflow:hidden;
- margin-bottom:6px;
- border:1px solid #DEDEDE;
- background-color: #333333;
- }
- #news_focus_turn_pic { position:relative; width:341px; height:280px; overflow:hidden; }
- #news_focus_turn_pic div { position:absolute; width:1600px; }
- #news_focus_turn_pic div li { float:left; }
- #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; }
- #news_focus_turn_btn { height:87px; overflow:hidden; margin:4px auto 0; padding-left:2px; }
- #news_focus_turn_btn li { display:inline; float:left; margin:0 0 0 4px; padding-top:3px; cursor:pointer; }
- #news_focus_turn_btn img { width:75px; height:73px; border:2px solid #FFF; filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; }
- #news_focus_turn_btn .current {}
- #news_focus_turn_btn .current img {
- border-color:#FFFFFF;
- filter:alpha(opacity=100);
- -moz-opacity:1.0;
- opacity:1.0;
- }
- #news_focus_turn_tx { position:relative; width:94%; margin:0 auto; padding:0px 3px; background:url(../images/dashed_bg.gif) repeat-x center top; }
- #news_focus_turn_tx h3 { padding-bottom:3px; font-size:14px; }
- #news_focus_turn_tx h3 a { color:#CCCCCC}
- #news_focus_turn_tx strong {
- position:absolute;
- top:14px;
- right:6px;
- color:#CCCCCC;
- }
- #news_focus_turn_tx p { height:80px; overflow:hidden; line-height:1.3em; }
- #news_focus_turn_tx p a {
- color:#CCCCCC;
- text-decoration:underline;
- }
- #news_focus_turn_tx .normal { display:none; }
- /* News Focus Turn style end */
复制代码 及页面div代码- <div id="news_focus_turn">
- <!--{if !empty( $_SBLOCK['picnews'])}-->
- <div id="news_focus_turn_pic">
- <div id="news_focus_turn_picList" style="left:0; top:0;">
- <ul>
- <!--{loop $_SBLOCK['picnews'] $pkey $pvalue}-->
- <li><a href="#action/viewnews/itemid/$pvalue[itemid]#"><img src="$pvalue['a_filepath']" alt="$pvalue[subject]" /></a></li>
- <!--{/loop}-->
- </ul>
- </div>
- </div>
- <div id="news_focus_turn_btn">
- <ul>
- <!--{eval $i = 0}-->
- <!--{loop $_SBLOCK['picnews'] $key $value}-->
- <!--{eval $current = ($i == 0 ? 'current' : 'normal');}-->
- <li class="$current"><img src="$value[a_thumbpath]" alt="$value[subject]" /></li>
- <!--{eval $i++}-->
- <!--{/loop}-->
- </ul>
- </div>
- <div id="news_focus_turn_tx">
- <ul>
- <!--{eval $i = 0}-->
- <!--{loop $_SBLOCK['picnews'] $bkey $bvalue}-->
- <!--{eval $current = ($i == 0 ? 'current' : 'normal');}-->
- <li class="$current"><h3><a href="$value[url]" >$bvalue[subject]</a></h3><strong>[#date('m.d', $bvalue['dateline'])#]</strong>
- <p>$bvalue[message]<a href="$bvalue[url]">阅读全文</a></p>
- </li>
- <!--{eval $i++}-->
- <!--{/loop}-->
- </ul>
- </div>
- <!--{/if}-->
- </div><!--news_focus_turn end-->
复制代码 |