好吧,我有一个加载3个画廊的页面,每个画廊都有"视图库"按钮。每次单击此按钮时,都应将整个图库加载到另一个页面中。它应该调用一个函数来加载整个图库并重定向到包含所有图像的页面。但我无法使其发挥作用。函数的参数通过变量" x"的值传递,但我不知道如何将此值放在函数中,因此重定向工作完美。像这样:
while(x <= 3){
imgs.innerHTML += "<div id='gal"+x+"' class='row'>";
imgs.innerHTML += "<div class='eight columns'>";
imgs.innerHTML += "<h4>Galeria "+x+"</h4>"
for(var i = 0; i <= 3; i++){
galeria[i] = "foto"+x+"_"+(i+1)+".jpg";
}
for(var i = 0; i < galeria.length; i++){
imgs.innerHTML += "<img src='img/"+galeria[i]+"' class='imgs-galeria'>";
}
imgs.innerHTML += "</div>";
imgs.innerHTML += "</div>";
imgs.innerHTML += "<a id='veja' href='pics.html' onclick='maisGaleria("+x+");'><div id='link'><p>Veja mais</p></div>"
//it loads the page pics.html and send the x value to the function. I need to start the function with this value in pics.html, but instead, it just load pics.html with no images.
x++;
}
功能:
function maisGaleria(n){
var galeria = new Array();
var img = $("#gallery");
img.innerHTML = "<div class='row'>";
img.innerHTML = "<div class='six columns'>";
//imgs.innerHTML += "<h4>Galeria"+n+"</h4>";
for(var i = 0; i <= 3; i++){
galeria[i] = "foto"+n+"_"+(i+1)+".jpg";
}
for(var i = 0; i < galeria.length; i++){
img.innerHTML += "<img src='img/"+galeria[i]+"' class='imgs-galeria'>";
}
img.innerHTML += "</div>";
img.innerHTML += "</div>";
}
页面pics.html
<body onload="maisGaleria();">
<div class="center">
<div class="row">
<div class="four columns top">
<h5></h5>
</div>
<div class="eight columns menu">
<ul>
<a href="index.html"><li><h4 class="menu-list">Home</h4></li></a>
<a href="galeria.html"><li><h4 class="menu-list">Galeria</h4></li></a>
<a href="sobre.html"><li><h4 class="menu-list">Sobre</h4></li></a>
<a href="contato.html"><li><h4 class="menu-list">Contato</h4></li></a>
</ul>
</div>
</div>
<div class="row galeria">
<div id="gallery" class="container">
</div>
</div>
<div class="row">
<div id="footer">
<div class="four columns">
<h4></h4>
</div>
<div class="eight columns img-footer" id="social">
</div>
</div>