Bonjour,

Je cherche à redimensionner ma fenêtre en fonction de la taille de son contenu en fait je voudrais qu'elle prenne la taille de l'image affichée dedans.


Donc j'ai fait des recherches et voilà ce que j'ai insérer dans ma page où s'affiche mon image :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Photo Ground</title>
<script language="JavaScript">
<!--
function resizePopUp(monImage, monTitre)
  {
  w = window.open('','chargement','width=10,height=10');
  w.document.write( "<html><head><title>"+monTitre+"</title>\n" ); 
  w.document.write( "<script language='JavaScript'>\n"); 
  w.document.write( "IE5=NN4=NN6=false;\n"); 
  w.document.write( "if(document.all)IE5=true;\n"); 
  w.document.write( "else if(document.getElementById)NN6=true;\n"); 
  w.document.write( "else if(document.layers)NN4=true;\n"); 
  w.document.write( "function autoSize() {\n"); 
  w.document.write( "if(IE5) self.resizeTo(document.images[0].width+10,
document.images[0].height+31)\n"); 
  w.document.write( "else if(NN6) self.sizeToContent();\n");
  w.document.write( "else window.resizeTo(document.images[0].width,
document.images[0].height+20)\n"); 
  w.document.write( "self.focus();\n"); 
  w.document.write( "}\n</scri");
  w.document.write( "pt>\n"); 
  w.document.write( "</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onLoad='javascript:autoSize();'>" );
  w.document.write( "<a href='javascript:window.close();'><img src='"+monImage+"' border=0 alt='"+monTitre+"'></a>" ); 
  w.document.write( "</body></html>" );
  w.document.close(); 
  }
-->
</script>
</head>
 
<body>
<?php
 $sql = "SELECT *
         FROM albums
         JOIN photos ON albums.num_album = photos.num_album
         WHERE photos.num_photo = ".(int)$_GET['numphoto'];
         $result = mysql_query($sql) or die ('Erreur SQL : impossible d\'effectuer la requête : <br />'.$sql);
         for($i=0;$i<mysql_num_rows($result);$i++)
         {
          $row=mysql_fetch_assoc($result);
          echo '<img border="0" src="images/albums/' . $row['nom_album'] . '/' . $row['img_photo'] . '" />';
         }
?> 
 
</body>
</html>
Ensuite je sais que dans mon href qui envoi vers ma page où s'affiche mon image je dois ajouter une onClick=resizePopUp malheureusement je ne vois pas comment écrire cela au milieu de mon code php voilà à quoi mon lien ressemble.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
echo '<TD background="images/menu/bg_vig.png" align="center" width="170">';
			echo '<a href="image.php?numphoto=' . $albums['num_photo'] . '">';
			echo '<img width="150" border="0" src="images/vignettes/'.$albums['vig_photo'].'"';
			echo '"</a></TD>';
Si quelqu'un peut m'aider merci