Eléphanteau du PHP |
30 Messages
16 nov. 2005, 20:14
Bonjour,
j'adore le code de Cyrano, c'est exactement ce dont j'ai besoin.
Par contre, en l'adaptant à mon besoin, il ne marche plus (il n'ouvre pas de popup

), et je ne suis pas assez calé pour voir d'où ca vient.
Une idée ?
Code : Tout sélectionner
function PopupImage(img,salargeur,sahauteur)
{
var titre=":: ZOOM ::";
var w = open("", 'image', 'top='+(screen.availHeight/2-300)+', left='+(screen.availWidth/2-300)+', width=salargeur, height=sahauteur, toolbar=no, scrollbars=no, resizable=no');
w.document.write("<html>\n");
w.document.write("<head>\n");
w.document.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" \/>\n");
w.document.write("<title>:: ZOOM ::<\/title>\n");
w.document.write("<meta http-equiv=\"imagetoolbar\" content=\"no\" \/>\n");
w.document.write("<script type=\"text\/javascript\">\n");
w.document.write("\/* <![CDATA[ *\/\n");
w.document.write("function checksize()\n");
w.document.write("{\n");
w.document.write(" if(document.images[0].complete)\n");
w.document.write(" {\n");
w.document.write(" if (document.images[0].width > 600) {\n");
w.document.write(" if (document.images[0].height > 600) {\n");
w.document.write(" if (document.images[0].height > document.images[0].width) {\n");
w.document.write(" tmp_zw = intval(600/(document.images[0].height/document.images[0].width)) ;\n");
w.document.write(" tmp_zh = 600 ;\n");
w.document.write(" }\n");
w.document.write(" else {\n");
w.document.write(" tmp_zw = 600 ;\n");
w.document.write(" tmp_zh = intval(600/(document.images[0].width/document.images[0].height)) ;\n");
w.document.write(" }\n");
w.document.write(" }\n");
w.document.write(" else {\n");
w.document.write(" tmp_zw = 600 ;\n");
w.document.write(" tmp_zh = intval(document.images[0].height/(document.images[0].width/600)) ;\n");
w.document.write(" }\n");
w.document.write(" }\n");
w.document.write(" else {\n");
w.document.write(" if (document.images[0].height > 600) {\n");
w.document.write(" tmp_zw = intval(document.images[0].width/(document.images[0].height/600)) ;\n");
w.document.write(" tmp_zh = 600 ;\n");
w.document.write(" }\n");
w.document.write(" else {\n");
w.document.write(" tmp_zw = document.images[0].width ;\n");
w.document.write(" tmp_zh = document.images[0].height ;\n");
w.document.write(" }\n");
w.document.write(" }\n");
w.document.write(" window.resizeTo(tmp_zw+24,tmp_zh+54);\n");
w.document.write(" window.focus();\n");
w.document.write(" }\n");
w.document.write(" else\n");
w.document.write(" {\n");
w.document.write(" setTimeout('check()',250);\n");
w.document.write(" }\n");
w.document.write("}\n");
w.document.write("\/\/]]>\n");
w.document.write("<\/script>\n");
w.document.write("<\/head>\n");
w.document.write("<body onload=\"checksize()\" style=\"margin: 0px;\">\n");
w.document.write("<p style=\"margin: 0; padding: 0\"><a href=\"#\" onclick=\"window.close();\" onmousedown=\"window.close();\"><img src=\"<?php echo $pathpic ; ?>\" style=\"border: none;\" ><\/a><\/p>\n");
w.document.write("<\/body>\n");
w.document.write("<\/html>\n");
w.document.close();
}
// Naturellement, $illus sera en vrai chargé avec une récup' de la base
$illus = "rod_ford36.jpg" ;
$pathpic = "../pic/deco/".$illus ;
list($width, $height, $type) = getimagesize($pathpic) ; // Largeur - Hauteur et type d'image (1 = GIF / 2 = JPG)
if ($width > 180) {
if ($height > 180) {
if ($height > $width) {
$tmp_w = intval(180/($height/$width)) ;
$tmp_h = 180 ;
}
else {
$tmp_w = 180 ;
$tmp_h = intval(180/($width/$height)) ;
}
}
else {
$tmp_w = 180 ;
$tmp_h = intval($height/($width/180)) ;
}
}
else {
if ($height > 180) {
$tmp_w = intval($width/($height/180)) ;
$tmp_h = 180 ;
}
else {
$tmp_w = $width ;
$tmp_h = $height ;
}
}
echo "<a href='#' style='border: none' title='Image agrandie' onclick='PopupImage(".$pathpic.",".$tmp_w.",".$tmp_h.")'><img src=".$pathpic." width=".$tmp_w." height=".$tmp_h." border=0></a>" ;