I have a PHP page and I want to redirect it first to a page (eg google.com) then to another page (eg bing.com).
To do this I\'m using the following:
head
Well, maybe you would like to open 2 page at the same time. You can control it by javascript.
Something like following code:
var open_link_google = window.open('','_parent');
open_link_google.location="http://www.google.com";
var open_link_yahoo = window.open('','_blank');
open_link_yahoo.location="http://www.yahoo.com";
Something like following code:
var open_link_google = window.open('','_parent');
open_link_google.location="http://www.google.com";
var open_link_yahoo = window.open('','_blank');
open_link_yahoo.location="http://www.yahoo.com";
I'm afraid the behavior as you've described it isn't possible. Exactly how would you expect this to work? How can a single browser window go to two pages at the same time? After all, the browser can't interpret your response headers until it receives the response. So there's no step in between the two lines of code you show, the browser receives them both in the same response.
Thinking in terms of the request/response nature of the web, re-consider what you're trying to do in order to meet the need you're addressing. You stated that:
I want to redirect it first to a page (eg google.com) then to another page (eg bing.com)
There's an order of events there:
The step where you're looking to interject is between 4 and 5 above. Naturally, you can't modify or in any way control Google's response so you can't have a Page 1 that you don't control respond with a redirect to Page 2. (Indeed, even if they did, it's either content or a redirect... not both.)
Off the top of my head there may be a workaround that might fit your needs. You could use frames to keep the user on your page while showing them the content of these other pages. Within your parent frame, which you would control, you can use JavaScript to set the various timers and other events which would direct the user from Page 1 to Page 2. (Is it instant? If so, why bother with Page 1 at all? Is it after a few moments? What should cause the redirect from Page 1 to Page 2?)