Bonjour,
Ce script fonctionne bien, mais le format (hauteur et largeur) de la photo qui s'affiche en grand, ne change pas quelque soit les paramètres hauteur/largeur (ici: 500x400) , par contre les paramètres hauteur/largeur des petites photos (ici: 60x50) sont pris en compte:
album.add("photo1.jpg", 500,400, "photo1.jpg" , 60,50, "légende de la photo");
merci de votre aide.
script ci-dessous:
<script type="text/JavaScript">
function creerAlbum(txtRepertoire) {
this.txtRepertoire=txtRepertoire;
this.photos=new Array;
this.add=addPhoto;
this.print=printAlbum;
this.view=viewPhoto;
}
function addPhoto(srcPhoto, largeurPhoto, hauteurPhoto, srcVignette, largeurVignette, hauteurVignette, txtLegende) {
var photo=new Object();
photo.srcPhoto=srcPhoto;
photo.largeurPhoto=largeurPhoto;
photo.hauteurPhoto=hauteurPhoto;
photo.srcVignette=srcVignette;
photo.largeurVignette=largeurVignette;
photo.hauteurVignette=hauteurVignette;
photo.txtLegende=txtLegende;
this.photos[this.photos.length]=photo;
}
function viewPhoto(indice) {
document.images["photoAlbum"].src=this.txtRepertoire+this.photos[indice].srcPhoto;
if (document.getElementById) {
document.getElementById("divLegende").innerHTML=this.photos[indice].txtLegende;
}
}
function printAlbum() {
document.write("<div style=\"text-align:center;font-size:0.85em\">");
for (var i=0; i<this.photos.length ; i++)
{
document.write("<a href=\"javascript:album.view("+i+")\"><img src=\""
+this.txtRepertoire+this.photos[i].srcVignette+"\" width=\""+this.photos[i].largeurVignette
+"\" height=\""+this.photos[i].hauteurVignette+"\" style=\"border:1px solid white\" title=\""
+this.photos[i].txtLegende+"\"></a>");
}
document.write("<img src=\""+this.txtRepertoire+this.photos[0].srcPhoto+"\" name=\"photoAlbum\"border=\"2\" hspace=\"3\">");
document.write("<div id=\"divLegende\">"+this.photos[0].txtLegende+"</div>");
document.write("</div>");
}
var album=new creerAlbum("img/");
album.add("photo1.jpg", 500, 400, "photo1.jpg", 60, 50, "photo n°1");
album.add("photo2.jpg", 700, 600, "photo2.jpg", 30, 20, "photo n°2");
album.add("photo3.jpg", 900, 800, "photo3.jpg", 80, 70, "photo n°3");
album.print();
</script>
Afficher la suite