Display image in javascript pop up window in PHP problem
Posted: Wed Nov 26, 2003 11:12 am
I have PHP and Javascript together to display an image in a pup up window. All seems to be working correctly ecxept for one thing. Some of the pictures show up on the bottom right hand corner of the screen, a little off the screen. And the pop up window is larger than the image.
I think this happend only to pictures I haven viewed before. One I veiw the image once the problem never happens again for that image.
Do I need to preload the image or somthing with javascript
Javascript
I think this happend only to pictures I haven viewed before. One I veiw the image once the problem never happens again for that image.
Do I need to preload the image or somthing with javascript
Code: Select all
<?php
echo "<a href="javascript:showPic('$dir/$image[$j]', '$image[$j]');">\n
<img src='$dir/$image[$j]' border='0' width='$image_width[$j]' height='$image_height[$j]'></a>\n"
?>Code: Select all
var picWin = null;
function showPic(pic, title){
if (picWin && !picWin.closed) picWin.close();
pageDoc = '<html><head><title>'+title+'</title></head>';
pageDoc += '<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">';
pageDoc += '<A href="javascript:window.close()"><img border=0 src="'+pic+'" alt="'+title+'"></a>';
pageDoc += '</body></html>';
thePic = new Image();
thePic.src = pic;
attr = 'width=' + thePic.width;
attr += ', height=' + thePic.height;
attr += ', left=' + (screen.availWidth/2 - thePic.width/2);
attr += ', top=' + (screen.availHeight/2 - thePic.height/2);
picWin = window.open('', 'picWin', attr);
picWin.document.write(pageDoc);
}