Help with redirect

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
l9pt5
Forum Newbie
Posts: 17
Joined: Wed Apr 11, 2007 10:41 am

Help with redirect

Post by l9pt5 »

I need some suggestion about redirecting a page. I've a php script that when a user choose an option from a drop down menu, a javascript open a new page at that moment for the user to input something, once it's done the user can click on the Close button to close this window. After that, I want the php script to redirect to some place (e.g. http://myplace.com) instead of remain at the drop down menu. Could someone tell me how to do this. Thanks...
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Post by PhpMachine »

This is easily done with JS.

For instance:

Code: Select all

document.location.href = "http://myplace.com";
or

Code: Select all

window.location.href = "http://myplace.com"
l9pt5
Forum Newbie
Posts: 17
Joined: Wed Apr 11, 2007 10:41 am

Post by l9pt5 »

Could you tell me where do I place this code?
PhpMachine
Forum Commoner
Posts: 42
Joined: Thu Apr 19, 2007 11:26 am

Post by PhpMachine »

One mistake of mine.
You do this in the opened window, not the opener window...

On the close button, set the following to the "onclick" attribute of the button:

Code: Select all

opener.location.href="http://myplace.com";
l9pt5
Forum Newbie
Posts: 17
Joined: Wed Apr 11, 2007 10:41 am

Post by l9pt5 »

Ok, I tried with the following, but it's not working. Am I missing something?

Code: Select all

<input style="color: #A52A2A" type=submit value="Close Window" onclick="javascript:window.location = 'http://www.yahoo.com';">
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

<input style="color: #A52A2A" type="submit" onClick="location.href='http://yahoo.com'">
Works for me
Post Reply