5
On the site I have several advertising banners. When I click on a banner, I am redirected to a page that counts clicks on the banner. After this count I am redirected to the page before the banner click and a new tab opens with the banner link. For that I have the following:
// $go_to_url é o link do banner
echo "<script>window.open('".$go_to_url."', '_blank');</script>";
// redirecciona para a página anterior ao clique no banner
$last_url = $_SERVER['HTTP_REFERER'];
echo "<script>window.location.replace('".$last_url."');</script>";
So far so good, but there is a problem that can happen, the browser ask permission to open pop-up windows, and in this case the client does not have time to accept because it is soon redirected to the previous page. Is there any way around this problem? For example when using php’s header() function, but this function does not allow you to open another tab.
If the banner link directs to a new one and then uses the header solves your problem?
– gmsantos
if I use the header I am redirected outside the site and this is not what I want. I want to stay on the site and in another tab the banner page is opened
– pc_oc
That’s exactly what I said in the reply below.
– gmsantos