Page 1 of 1

Display image in javascript pop up window in PHP problem

Posted: Wed Nov 26, 2003 11:12 am
by Mo
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

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"
?>
Javascript

Code: Select all

var picWin = null;
function showPic(pic, title)&#123;
	if (picWin &amp;&amp; !picWin.closed) picWin.close();
	pageDoc = '&lt;html&gt;&lt;head&gt;&lt;title&gt;'+title+'&lt;/title&gt;&lt;/head&gt;';
	pageDoc += '&lt;body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0"&gt;';
	pageDoc += '&lt;A href="javascript:window.close()"&gt;&lt;img border=0 src="'+pic+'" alt="'+title+'"&gt;&lt;/a&gt;';
	pageDoc += '&lt;/body&gt;&lt;/html&gt;';
	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);
&#125;

Posted: Fri Nov 28, 2003 6:50 pm
by Mo
Can anyone help me with this?

Posted: Fri Nov 28, 2003 10:20 pm
by xisle
add + 5 pixels to the image_height and width then pass those params to the function. Pop the window with those height and width atrributes..

Posted: Wed Dec 10, 2003 1:58 pm
by Mo
I did this and it didn't fix my problem.

You can see the problem here http://babejordan.com/photo_imaging.php ... /airplane/.

I dont even know if I did it correctly. This is what my code looks like after the change:

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]'+5 height='$image_height[$j]'+5></a>\n" 
?>

Posted: Wed Dec 10, 2003 2:23 pm
by Saethyr
I was just there and everything seems to functioning normally.

Saethyr

Posted: Thu Dec 11, 2003 6:24 am
by Mo
Try any of the links on this page:

http://babejordan.com/photos.php