Ne ringraziare l'amico kluster per la sua gentile risposta, visto che adesso sembra funzionare, riporto per chi fosse interessato, il mio acrocchio.
Ho una pagina server che, cliccando su una miniatura, fa aprire un popup con l'immagine.
codice:
<a href="javascript:void(0);" onclick="CaricaFoto('****;return false;" >
DA NON DIMENTICARE PER NESSUNA RAGIONE, il return false
la funzione CaricaFoto crea il popup
codice:
var w_2 = null;
function CaricaFoto(foto1)
{
if (w_2 != null && w_2.open) w_2.close();
w_2 = window.open("", "foto2", "width=300px,height=300px,resizable=yes,scrollbars=no");
d = w_2.document;
d.writeln("<h"+"tml>");
d.writeln("<h"+"ead>");
d.writeln("<t"+"itle>" + foto1 + "</t"+"itle>");
d.writeln( "<SCRIP" + "T LANGUAGE=javascript>function ridimensiona(){window.setTimeout(function() {onsetTimeoutRidimensiona();}, 300);}function onsetTimeoutRidimensiona(){var foto1 = document.getElementById('im1');var maxW = screen.width - 70, maxH = screen.height - 100;var fattoreW, fattoreH, oldW, oldH, newW, newH;oldW = foto1.width;oldH = foto1.height;fattoreW = maxW / oldW;fattoreH = maxH / oldH;if(fattoreW >= fattoreH){ newW = oldW * fattoreH; newH = oldH * fattoreH; } else { newW = oldW * fattoreW; newH = oldH * fattoreW; } if(newW < foto1.width) {foto1.width = newW;} var largh = foto1.width -0 + 20; var altez = newH -0 + 20; window.resizeTo(foto1.width - 0 + 10, foto1.height - 0 + 50); } </SCRIP" + "T>");
d.writeln( "</h"+"ead>" );
d.writeln( "<b"+"ody topmargin='0' leftmargin='0' scroll='no' style='OVERFLOW: hidden'>" );
d.writeln( "[img]img1.aspx?img=" + foto1 + "&tic=" + (new Date()).valueOf() + "[/img]" ) ;
d.writeln( "</b"+"ody>" );
d.writeln( "</h"+"tml>" );
d.close();
w_2.focus();
}
l'html generato è:
codice:
<html>
<head>
<title>c:\DSCN0041.JPG</title>
<SCRIPT LANGUAGE=javascript>
function ridimensiona()
{
window.setTimeout(function()
{
onsetTimeoutRidimensiona();
}, 300);
}
function onsetTimeoutRidimensiona()
{
var foto1 = document.getElementById('im1');
var maxW = screen.width - 70, maxH = screen.height - 100;
var fattoreW, fattoreH, oldW, oldH, newW, newH;
oldW = foto1.width;
oldH = foto1.height;
fattoreW = maxW / oldW;
fattoreH = maxH / oldH;
if(fattoreW >= fattoreH)
{
newW = oldW * fattoreH;
newH = oldH * fattoreH;
}
else
{
newW = oldW * fattoreW;
newH = oldH * fattoreW;
}
if(newW < foto1.width) {foto1.width = newW; }
var largh = foto1.width -0 + 20;
var altez = newH -0 + 20;
window.resizeTo(foto1.width - 0 + 10, foto1.height - 0 + 50);
}
</SCRIPT>
</head>
<body topmargin='0' leftmargin='0' scroll='no' style='OVERFLOW: hidden'>
[img]img1.aspx?img=c:\DSCN0041.JPG&tic=1129632724296[/img]
</body>
</html>
l'immagine è richiamata dal server aggiungendo il parametro tic diverso per ogni chiamata, tanto per non avere problemi con la cache.
Da ultimo, se trovaste delle sciochezze, ben felice di saperlo. Ciao