根据我数组得到的值实现如 http://product.danawa.com.cn/79731/index.html
 的效果

解决方案 »

  1.   

    http://blog.csdn.net/hy_lihuan/archive/2007/02/09/1506408.aspx这个功能你看看是不是有一点类似阿?改变一下应该可以把
      

  2.   

    <script>
    function ProdPic(url)
    {
    this.url = url;
    }
    var ProdPicList = new Array();
    var iCount = 1;
    var iEnd=0;
    ProdPicList[0] = new ProdPic("http://images1.danawa.com.cn/china_sImages2/CAA/CEL20060531115138390.jpg");
    ProdPicList[1] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557580.621478.jpg");
    ProdPicList[2] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557580.886834.jpg");
    ProdPicList[3] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.067359.jpg");
    ProdPicList[4] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.2674.jpg");
    ProdPicList[5] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.588347.jpg");
    ProdPicList[6] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211557590.916552.jpg");
    ProdPicList[7] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.19166.jpg");
    ProdPicList[8] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.388924.jpg");
    ProdPicList[9] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.589709.jpg");
    ProdPicList[10] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558000.740137.jpg");
    ProdPicList[11] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558380.72252.jpg");
    ProdPicList[12] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558380.940921.jpg");
    ProdPicList[13] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.109084.jpg");
    ProdPicList[14] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.342582.jpg");
    ProdPicList[15] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.524367.jpg");
    ProdPicList[16] = new ProdPic("http://images1.danawa.com.cn/upload_50/CAA/CEL/200609211558390.752372.jpg");
    function next()
    {
    if (iCount >= ProdPicList.length){
    iCount = 0;//如果超出数组的长度就置为0
    }
    iEnd=iCount+4;//以4为步长进行递增
    if(iEnd>ProdPicList.length){
    iEnd=ProdPicList.length;//iEnd变量也不能超出数组的长度
    }
    if(ProdPicList.length<=4){
    //do nothing
    }else{
    for(var i=1;iCount<iEnd;iCount++,i++){//开始每次的循环输出
    document.getElementById("img_prod"+i).src = ProdPicList[iCount].url;
    }
    }
    }function pre()
    {   
    if(iCount==0){
    iCount=ProdPicList.length-1;
    }
    iEnd=iCount-4;
    if(iEnd<0){
    iEnd=0;
    }
    if(ProdPicList.length<=4){
    //do nothing
    }else{
    for(var i=1;iCount>iEnd;iCount--,i++){
    document.getElementById("img_prod"+i).src = ProdPicList[iCount].url;
    }
    }
    }function init(){
    var arrayLength=ProdPicList.length;
    if(arrayLength>4){
    arrayLength=4;
    }
    for(var i=0;i<arrayLength;i++){
    var index=i+1;
    document.getElementById("img_prod"+index).src = ProdPicList[i].url;
    }
        
    }
    function ShowImage(image_name) {
        var url=document.getElementById(image_name).src.replace("upload_50","upload_283").replace("china_sImages2","china_283");
        document.images["prod_img"].src =url;
    }
    </script>
    <style>
    #ziliao201 {width:60px; display:inline}
    </style>
    <body onload="init()">
    <table width="283" height="283"  border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td align="center" valign="middle" ><a href="http://product.danawa.com.cn/79731/pic.html"><img src="http://images1.danawa.com.cn/china_283/CAA/CEL20060531115138390.jpg" name="prod_img" id="prod_img" border="0" alt="图片"/></a></td>
    </tr>
    </table>
      <table width="312" height="55"  border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="16" valign="middle"><a href="#" onClick="javascript:pre();return false;"><img src="http://images1.danawa.com.cn/images/page_pic/data25.gif" border="0" /></a></td>
          <td width="100%">
          
         <div id="ziliao201">
      <table class="ziliao200">
            <tr>
               <td align="center" valign="middle" width="50" height="50" onMouseOver="javascript:ShowImage('img_prod1');"><a href="http://product.danawa.com.cn/79731/pic.html"><img src="http://product.danawa.com.cn/images/danawa/blank.gif" border="0" id="img_prod1"/></a></td>
            </tr>
          </table>
      </div>
    <div id="ziliao201">
      <table class="ziliao200">
            <tr>
               <td align="center" valign="middle" width="50" height="50" onMouseOver="javascript:ShowImage('img_prod2');"><a href="http://product.danawa.com.cn/79731/pic.html"><img src="http://product.danawa.com.cn/images/danawa/blank.gif" border="0" id="img_prod2"/></a></td>
            </tr>
          </table>
      </div>
          <div id="ziliao201">
      <table class="ziliao200">
            <tr>
               <td align="center" valign="middle" width="50" height="50" onMouseOver="javascript:ShowImage('img_prod3');"><a href="http://product.danawa.com.cn/79731/pic.html"><img src="http://product.danawa.com.cn/images/danawa/blank.gif" border="0" id="img_prod3"/></a></td>
            </tr>
          </table>
      </div>
          <div id="ziliao201">
      <table class="ziliao200">
            <tr>
               <td align="center" valign="middle" width="50" height="50" onMouseOver="javascript:ShowImage('img_prod4');"><a href="http://product.danawa.com.cn/79731/pic.html"><img src="http://product.danawa.com.cn/images/danawa/blank.gif" border="0" id="img_prod4"/></a></td>
            </tr>
          </table>
      </div>
          </td>
          <td width="16" valign="middle"><a href="#" onClick="javascript:next();return false;"><img src="http://images1.danawa.com.cn/images/page_pic/data24.gif" width="12" height="13" border="0" /></a></td>
        </tr>
      </table>
      

  3.   

    <html>
    <head>
    <style>
    #g_div{text-align:right;overflow:hidden}
    .b{width:24px; height:16px; background:#737373; font-size:14px; font-weight:bold; color:#fff; text-decoration:none;margin-left:1px}
    .b:hover{width:24px; height:16px; background:#780001; font-size:14px; font-weight:bold; color:#fff; text-decoration:none;margin-left:1px}
    .bhover{width:24px; height:16px; background:#780001; font-size:14px; font-weight:bold; color:#fff; text-decoration:none;margin-left:1px}
    </style>
    </head>
    <body>
    <div id="g_div" style="width:270px;height:252px"><a 
    href="#" target=_blank><img 
    id="g_img" style="FILTER:revealTrans(duration=1,transition=23);width:266px;height:220px;border:1px green solid" src="http://zi.csdn.net/xian.gif">
    </a><a 
    href="http://www.baidu.com/" for="http://zi.csdn.net/xian.gif"  target="_blank">1.CSDN程序员</a><a 
    href="http://www.126.com/" for="http://zi.csdn.net/microsoft280_187.jpg"  target="_blank">2.CSDN程序员</a><a 
    href="http://mp3.baidu.com/"  for="http://zi.csdn.net/live.gif"   target="_blank">3.CSDN程序员</a><a 
    href="http://post.baidu.com/" for="http://zi.csdn.net/new-mba.gif"  target="_blank">4.CSDN程序员</a><a 
    href="http://top.baidu.com/" for="http://zi.csdn.net/book.jpg"  target="_blank">5.CSDN程序员</a>
    </div><script language="JavaScript">
    function f(){
    var g_sec=3          //几秒后切换图片
    var g_items=new Array()
    var g_div=document.getElementById("g_div") 
    var g_img=document.getElementById("g_img") 
    var g_imglink=g_img.parentElement
    var arr=g_div.getElementsByTagName("A")
    var arr_length=arr.length
    var g_index=1var show_img=function(n){  
       if (/\d+/.test(n)){
    var prev=g_index+1
    g_index=n-1
       }else{   
    var prev=(g_index>arr.length)?(arr_length-1):g_index+1
    g_index=(g_index<arr_length-2)?(++g_index):0
       } 
       if (document.all){
       g_img.filters.revealTrans.Transition=23;
      g_img.filters.revealTrans.apply();
      g_img.filters.revealTrans.play();
        }
     arr[prev].className="b"  
     arr[g_index+1].className="bhover"
     g_img.src=g_items[g_index].img.src
     g_img.title=g_items[g_index].txt
     g_imglink.href=g_items[g_index].url  
     g_imglink.target=g_items[g_index].target
      
    }for(var i=1;i<arr_length;i++){
    g_items.push({txt:arr[i].innerHTML,
    url:arr[i].href,
    target:arr[i].target,
    img:(function(){var o=new Image;o.src=arr[i].getAttribute("for");return o})()}) 
    arr[i].title=arr[i].innerHTML
    arr[i].innerHTML=[i,"&nbsp;"].join("")
    arr[i].className="b"
    arr[i].onclick=function(){
    event.returnValue=false;
    show_img(event.srcElement.innerText)
    }
    }
    show_img(1)
    var t=window.setInterval(show_img,g_sec*1000) 
    g_img.onmouseover=function(){window.clearInterval(t)}
    g_img.onmouseout=function(){t=window.setInterval(show_img,g_sec*1000)}  
    }window.attachEvent("onload",f) 
    </script>
    </body>
    </html>