I have seen this question being asked many times here, but I couldn't get an answer that works!
i am trying to redirect to a load.php TO A NEW TAB using the following script:
echo '<script>window.open("load.php","_blank)</script>';
for some reason it is not working and it stays on the same page.
i am using chrome!
is there any possible way to redirect to a new tab? thanks a lot
Most browsers will block window.open
unless it is a result of a direct user interaction i.e. the onclick
event handle of an anchor tag being fired.
There are ways you can try and "trick" popup blockers, but it is unreliable and considered bad practice. If a user has chosen to enable a popup blocker, it should be respected.
What I would suggest is to also add a link on your page along the lines of the following:
<a href="load.php" target="_blank">Click here</a> if the window does not open in a seperate window.
This would ensure that the user can still open the window manually should it be supressed by a popup blocker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With