Salut Pépette,
Oui ton code comportait quelques petites erreurs, le revoici donc corrigé:
<SCRIPT LANGUAGE="JavaScript">
function PopupImage(img) {
if (img=="photos/accueil.jpg") { titre="Bienvenue"; }
w=open("",'image','width=400,height=400,toolbar=no,scrollbars=yes,resizable=yes');
w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>");
w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+25,document.images[0].height+75); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+img+"' border=0>");
w.document.write("<p align='center'><a href='javascript:window.close()'>Fermer</a></p>");
w.document.write("");
w.document.write("</BODY></HTML>");
w.document.close();
}
</SCRIPT>
Comme je te l'avais dit, ce script s'adapte à la taille de l'image (grâce à la fonction "checksize") et fait un test au début de la fonction pour afficher le titre. C'est pratique si tu as plusieurs images.
Si tu n'as qu'une seule image à ouvrir (ça a l'air d'être le cas), alors tu n'as pas besoin de tout ça.
Revoici le code simplifié:
*Tout d'abord le lien sur ton image:
<a href="javascript:PopupImage()"><img src="photos/accueil.jpg" alt="Agrandir l'image" width="450" height="320" border="0"></a>
*Et enfin le script:
<SCRIPT LANGUAGE="JavaScript">
function PopupImage() {
w=open("",'image','width=463,height=370,toolbar=no,scrollbars=yes,resizable=yes');
w.document.write("<HTML><HEAD><TITLE>Bienvenue</TITLE></HEAD>");
w.document.write("<BODY leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='photos/accueil.jpg' border=0>");
w.document.write("<p align='center'><a href='javascript:window.close()'>Fermer</a></p>");
w.document.write("");
w.document.write("</BODY></HTML>");
w.document.close();
}
</SCRIPT>
Tu constateras par ailleurs qu'il y a un lien pour fermer le pop-up. Tu peux bien sûr le supprimer, le remplacer par un bouton ou encore changer son style.
Si tu as des questions, n'hésite pas.
Bon courage et @+