popup window

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bmac11
Forum Newbie
Posts: 9
Joined: Thu Feb 17, 2005 3:14 pm

popup window

Post by bmac11 »

Why doesn't this work? The link works. It just doesnt open in a popup window.

Code: Select all

$link_popup = "<a href='x.php' onclick='window.open('x.php','popup','width=500,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false'>Test Popup</a><BR>";

echo $link_popup . "<BR>";

I when I use it only in html, it works, but I would like to pass a php variable to the new window too.

Code: Select all

?>
<a href="x.php" onclick='window.open('x.php','popup','width=500,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false'>Test Popup</a>
<?php
How can I get either one to work?
thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

technically, neither works.

Code: Select all

$link_popup = '<a href="x.php" onclick="window.open(\'x.php\',\'popup\',\'width=500,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0\'); return false">Test Popup</a><BR>';

echo $link_popup . '<br />';
Last edited by feyd on Fri Mar 11, 2005 8:41 am, edited 2 times in total.
bmac11
Forum Newbie
Posts: 9
Joined: Thu Feb 17, 2005 3:14 pm

Post by bmac11 »

Is there a way I can pass a php variable to a popup window? If so, please point me in the right direction on how to go about creating one.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can pass it via sessions, or through the url you use to create the popup. Just be aware that most people have popup blockers now, and are likely to not turn them off.
jonemo
Forum Commoner
Posts: 28
Joined: Wed Feb 09, 2005 1:32 pm
Location: london, uk

Post by jonemo »

keep in mind, that most popupblockers don't block popups that open by user actions like a click. they just keep popups that happen without any user action.
bmac11
Forum Newbie
Posts: 9
Joined: Thu Feb 17, 2005 3:14 pm

Post by bmac11 »

I'm still a little confused. If I use

Code: Select all

$link_popup = "<a href='x.php' onclick='window.open('x.php','popup','width=500,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false'>Test Popup</a>";

echo $link_popup . "<BR>";
it doesnt open the new popup window. It only opens it in current window.

But if I do it without php (only in html), it works, but then I can't pass a php variable to it.
rjwebgraphix
Forum Newbie
Posts: 11
Joined: Fri Mar 11, 2005 8:10 am

Post by rjwebgraphix »

feyd wrote:Just be aware that most people have popup blockers now, and are likely to not turn them off.
There is code somewhere, somehow to bypass popup blockers. Using the standard OnClick will not work. I find many popup blockers will block any of the standard methods.

I have seen sites that do a popup for a contact form that the popup blocker does not block.

I was hoping by searching through messages that I could find something that would work, but unfortunantly it doesn't look like it.

Sites do have legitimate reasons for not loading a whole new page just for a small contact form, which is my usage, but don't want the popup blocked by popup blockers, just like I've seen on other sites.

I'm assuming this must be done server side some kind of way, but I may be wrong as it should normally be the client side that executes a popup window.

Any ideas how you can popup a window and not have a popup blocker block that popup??????

Any help would be appreciated.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can use a visibility trick, where you "pop" a pane containing the information. It's contained in the page, and typically will not be blocked by a blocker.. Some browsers will only block a popup until you request the popup by clicking on something that'd normally generate one. However IE does not support such an action at this time (that I remember anyway)
Post Reply