简体   繁体   中英

Edit only javascript to add slideshow from images array

all I have a lot of html pages on the server that opens each big image into a new window calling just one external javascript file. I would like to edit this javascript so when I click on an image they all can be viewed using Prev and Next links buttons.

here's the html code for images:

<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>

and here's the code from javascript file:

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);
}

我想你想用滑块制作灯箱找到这个插件: 这里

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM