Forum Moderators: coopster

Message Too Old, No Replies

php header(Location: ) and window.open()

How to do them in the same php file?

         

birdgajk

7:54 am on Dec 11, 2003 (gmt 0)



I would like to redirect the page using php header(Location: ) And at the same time, open a pop up window using window.open()

Since the header() has to be the first output, after the page redirected by header(Location: ), the window.open() is not executed.

Any solution to reslove the problem there? Thanks

stargeek

7:59 am on Dec 11, 2003 (gmt 0)

10+ Year Member



you cannot use php's header after you have sent javascript to te browser, but how about redirecting with javascript's top.href.location after you open the pop up?

jetboy_70

3:01 pm on Dec 11, 2003 (gmt 0)

10+ Year Member



Not tried this, but how about:

window.open('popup.php?id=<?php echo urlencode($mylocation;)?>')

in the parent file, and:

header('Location: '.urldecode($_POST['id']));

as the first line in the child (popup.php).

Apologies if the syntax is dodgy, but it should be enough to get the idea.