Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make a link open a popup window?

PHP and Popup windows

How do I make a link open a popup window?

by  JustKIDn  Posted    (Edited  )
I needed a way to make a photo display script show a photo when clicked in a new window. I didn't write the original photo display script myself but I did modify it. Including adding the popup window effect.

This is what I started with:
Code:
echo "<td align=center><a href=\"$images[$i]\">$images[$i]<BR><BR><img border=0 src=\"thumbs/$thumb[$i]\"></a><BR><BR></td>";

This example would only open the image in the same browser window. So then I would have to hit the back button to return and then wait for all the pictures to be redrawn again.

I was concerned about using javascript because of the possibilities of errors.

I got most of my help from this page;
http://youngpup.net/_ui_webapp/getFrames.asp?request=/articles/how-to-create-popups.xml

This is what I came up with:
Code:
   echo "<td align=center><a href=\"$images[$i]\" onclick=\"window.open(this.href, 'popupwindow', 'height=500,width=655,scrollbars,resizable'); return false;\"><BR><img border=0 src=\"thumbs/$thumb[$i]\"><br /> </a></td>";

You can replace $images[$i] with your actual page or image name. And the same is true for img src.

Important Note: Figuring out the correct placement of the quotes was the hard part!
[color red]Watch for the placement of quotes (")! [/color]

Hope this helps!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top