仅编辑javascript以从images阵列添加幻灯片

时间:2015-10-08 08:07:55

标签: javascript html css image slideshow

所有 我在服务器上有很多html页面,它们将每个大图像打开到一个新窗口,只调用一个外部javascript文件。 我想编辑这个javascript,所以当我点击图片时,他们都可以使用Prev和Next链接按钮查看。

这里是图片的html代码:

<td><a href="moreimages/imagebig01.jpg" onclick="NewWindow(this.href,'mywin','640','640','no','center');return false" onfocus="this.blur()" class="styling"><img src="moreimages/imagesmall01.jpg" width="70" border="0" alt="image small 1" title="image small 1"></a></td>

<td><a href="moreimages/imagebig02.jpg" onclick="NewWindow(this.href,'mywin','640','640','no','center');return false" onfocus="this.blur()" class="styling"><img src="moreimages/imagesmall02.jpg" width="70" border="0" alt="image small 2" title="image small 2"></a></td>

<td><a href="moreimages/imagebig03.jpg" onclick="NewWindow(this.href,'mywin','640','640','no','center');return false" onfocus="this.blur()" class="styling"><img src="moreimages/imagesmall01.jpg" width="70" border="0" alt="image small 3" title="image small 3"></a></td>

<td><a href="moreimages/imagebig04.jpg" onclick="NewWindow(this.href,'mywin','640','640','no','center');return false" onfocus="this.blur()" class="styling"><img src="moreimages/imagesmall04.jpg" width="70" border="0" alt="image small 4" title="image small 4"></a></td>

这里是来自javascript文件的代码:

var imagesArray = []; //array to hold all images from moreimages.html
function getImageLinks() {
  var a = document.getElementsByTagName("a") //get all elements that have <a> tag
  for (h in a) { // walk thru this elements
     var href = a[h].attributes['href']; //from an <a> element get his href attribute
     if (href) { // check if <a> tag has a href attribute
          imagesArray.push(href.value); //add the value of href (image link) to the array
    }
  }
  }
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){
        LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
        TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
    }
    if(pos=="center"){
        LeftPosition=(screen.width)?(screen.width-w)/2:100;
        TopPosition=(screen.height)?(screen.height-h)/2:100;
    }
    else 
        if((pos!="center" && pos!="random") || pos==null){
            LeftPosition=0;TopPosition=20
    }

    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);
}

1 个答案:

答案 0 :(得分:0)

我想你想制作带滑块的灯箱 找到这个插件:here