On the site I have several banner ads. When I click on a banner, I'm redirected to a page that counts clicks on the banner. After this count I'm redirected to the page before the click on the banner and a new tab with the banner link opens. For this 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 asks 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 the header () function of php, but this function does not allow to open another tab.