在外国学习business,有门课非得自己做一个商业网站,我完全就不是计算机专业的学生,所以dreamweaver完全就是新手,时间还非常紧,想在主页添加一个图片自动切换并且图片和一个文字选择栏有关联,就是点选文字也可以切换图片。网上的很多代码我都看不懂,而且复制下来使用也都不成功,那位专家,大牛,帮小妹一个忙吧,已经看抗不下去了

解决方案 »

  1.   

    这个很简单的。网上很多吧。自己做个也很简单的
    http://www.google.com/search?q=%E5%9B%BE%E7%89%87%E5%88%87%E6%8D%A2%E6%95%88%E6%9E%9C&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:zh-CN:official&client=firefox-a#sclient=psy&hl=en&newwindow=1&client=firefox-a&hs=Vk2&rls=org.mozilla:zh-CN%3Aofficial&source=hp&q=jquery+%E5%9B%BE%E7%89%87%E5%88%87%E6%8D%A2%E6%95%88%E6%9E%9C&aq=f&aqi=&aql=&oq=&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=6960e17a20b80511
    http://www.pecloud.cn/jquery-%E5%9B%BE%E7%89%87%E5%88%87%E6%8D%A2%E6%95%88%E6%9E%9C
      

  2.   

    建立3个文件分别命名为:index.htm,picturn.js,picturn.css
    图片显示页index.htm<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>首页</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
    <link rel="stylesheet" type="text/css" id="cssLink" href="picturn.css"/>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="picturn.js"></script>
    </head>
    <body>
     <div id="picBox_top">
      <ul id="show_pic_top" style="top:0;">
            <li><img src="images/1.jpg" width="520" height="150" alt="" title="" /></li>
            <li><img src="images/2.jpg" width="520" height="150" alt="" title="" /></li>
            <li><img src="images/3.jpg" width="520" height="150" alt="" title="" /></li>
            <li><img src="images/4.jpg" width="520" height="150" alt="" title="" /></li>
            <li><img src="images/5.jpg" width="520" height="150" alt="" title="" /></li>
        </ul>
        <ul id="icon_num_top">
         <li class="active">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
    </body>
    </html>
    图片切换代码的JS页:picturn.js
    /*
     图片切换代码
     *glide.layerGlide((oEventCont,oSlider,sSingleSize,sec,fSpeed,point);
     *@param auto type:bolean 是否自动滑动 当值是true的时候 为自动滑动
     *@param oEventCont type:object 包含事件点击对象的容器
     *@param oSlider type:object 滑动对象
     *@param sSingleSize type:number 滑动对象里单个元素的尺寸(width或者height)  尺寸是有point 决定
     *@param second type:number 自动滑动的延迟时间  单位/秒
     *@param fSpeed type:float   速率 取值在0.05--1之间 当取值是1时  没有滑动效果
     *@param point type:string   left or top
     */
    var glide =new function(){
     function $id(id){return document.getElementById(id);};
     this.layerGlide=function(auto,oEventCont,oSlider,sSingleSize,second,fSpeed,point){
      var oSubLi = $id(oEventCont).getElementsByTagName('li');
      var interval,timeout,oslideRange;
      var time=1; 
      var speed = fSpeed 
      var sum = oSubLi.length;
      var a=0;
      var delay=second * 1000; 
      var setValLeft=function(s){
       return function(){
        oslideRange = Math.abs(parseInt($id(oSlider).style[point])); 
        $id(oSlider).style[point] =-Math.floor(oslideRange+(parseInt(s*sSingleSize) - oslideRange)*speed) +'px';  
        if(oslideRange==[(sSingleSize * s)]){
         clearInterval(interval);
         a=s;
        }
       }
      };
      var setValRight=function(s){
       return function(){   
        oslideRange = Math.abs(parseInt($id(oSlider).style[point]));       
        $id(oSlider).style[point] =-Math.ceil(oslideRange+(parseInt(s*sSingleSize) - oslideRange)*speed) +'px';
        if(oslideRange==[(sSingleSize * s)]){
         clearInterval(interval);
         a=s;
        }
       }
      }
      
      function autoGlide(){
       for(var c=0;c<sum;c++){oSubLi[c].className='';};
       clearTimeout(interval);
       if(a==(parseInt(sum)-1)){
        for(var c=0;c<sum;c++){oSubLi[c].className='';};
        a=0;
        oSubLi[a].className="active";
        interval = setInterval(setValLeft(a),time);
        timeout = setTimeout(autoGlide,delay);
       }else{
        a++;
        oSubLi[a].className="active";
        interval = setInterval(setValRight(a),time); 
        timeout = setTimeout(autoGlide,delay);
       }
      }
     
      if(auto){timeout = setTimeout(autoGlide,delay);};
      for(var i=0;i<sum;i++){ 
       oSubLi[i].onmouseover = (function(i){
        return function(){
         for(var c=0;c<sum;c++){oSubLi[c].className='';};
         clearTimeout(timeout);
         clearInterval(interval);
         oSubLi[i].className="active";
         if(Math.abs(parseInt($id(oSlider).style[point]))>[(sSingleSize * i)]){
          interval = setInterval(setValLeft(i),time);
          this.onmouseout=function(){if(auto){timeout = setTimeout(autoGlide,delay);};};
         }else if(Math.abs(parseInt($id(oSlider).style[point]))<[(sSingleSize * i)]){
           interval = setInterval(setValRight(i),time);
          this.onmouseout=function(){if(auto){timeout = setTimeout(autoGlide,delay);};};
         }
        }
       })(i)   
      }
     }
    }
    window.onload=function(){
    if(document.getElementById('picBox_top')!=null)
    {glide.layerGlide(true,'icon_num_top','show_pic_top',150,3,0.1,'top');}

    }
    CSS文件:picturn.css:
    #picBox{float:left;width:520px; height:150px; margin:5px auto; overflow:hidden; position:relative;}
    #picBox ul#show_pic{margin:0; padding:0; list-style:none; height:150px; width:3050px; position:absolute;}
    #picBox ul#show_pic li{ float:left; margin:0; padding:0; height:150px;}
    #picBox ul#show_pic li img{display:block;}
    #icon_num{ position:absolute; bottom:0px; right:10px;}
    #icon_num li{ float:left; background:url(images/11.gif) no-repeat -15px 0;width:15px; height:15px; list-style:none; color:#39F; text-align:center;  cursor:pointer; padding:0; margin:0;margin-right:5px;}
    #icon_num li:hover,#icon_num li.active{ background:url(images/11.gif) no-repeat 0 0; color:#fff;}
    #picBox_top{width:520px; height:150px; margin:5px auto; position:relative; overflow:hidden;}
    #picBox_top ul#show_pic_top{ margin:0; padding:0; list-style:none; height:150px; width:520px; position:absolute;}
    #picBox_top ul#show_pic_top li{ float:left; margin:0; padding:0; height:150px;}
    #picBox_top ul#show_pic_top li img{ display:block;}
    #icon_num_top{position:absolute; bottom:0px; right:10px;}
    #icon_num_top li{ float:left; background:url(images/11.gif) no-repeat -15px 0;width:15px; height:15px; list-style:none; color:#39F; text-align:center;  cursor:pointer; padding:0; margin:0;margin-right:5px;}
    #icon_num_top li:hover,#icon_num_top li.active{ background:url(images/11.gif) no-repeat 0 0; color:#fff;}最后在引入一个小型的jquery库文件,并建立一个images文件夹,放入1,2,3,4,5.jpg的图片即可!