Jon
Jon

Reputation: 43

PHP redirect: Chrome closes window

I need to do some redirects after processing in PHP. This processing is done in a new window after a link is clicked. However, in Chrome, whenever I try to click the link, it closes right away, somehow sensing and blocking the redirect right away. It works if the link is not opened with target="_blank".

Sites like Pricerunner handle the redirect flawlessly: http://www.pricerunner.co.uk/pli/2-3155408/TVs/Samsung-UE40KU6000-Compare-Prices.

How do I make my site work like Pricerunner? Should I skip target="_blank" and do some JavaScript handling instead?

Upvotes: 1

Views: 199

Answers (1)

Snickbrack
Snickbrack

Reputation: 966

PHP

try to create a redirecting page with following two lines of code:

header("your/site/page.php");
exit();

it will send a response header with a redirect to the browser. And exit() will stop all the execution after this point. So the further loading will cancel here and the new page will "load".

Upvotes: 1

Related Questions