I need to open a new URL after a post request. I have done this at the end of my controller.
Redirect::away($url)
The above calls works perfect, however, I want to open the URL in a new tab.
I tried to, away, and intended methods that are there in the laravel doc. None work as intended.
Laravel or (PHP in general) is a server side and we cannot open a new tab in them, because the new tab is browser thing so the solution is to do it in front side like: using <a> TAG <a href="#Link" target="_blank">New tab</a> . using popup javascript window.
Redirect::away()
or Redirect:to()
both are server side commands and all they do is to redirect to a url with a slight difference as mentioned in this thread
As, both are server side commands they cannot open a new tab.
You need client side code to open new tab, for example:
<a href="#" target="_blank">Open in a new tab</a>
I know this is an old question, but for reference you can cause a client redirect to a new window/tab from the server using
echo "<script>window.open('".$url."', '_blank')</script>";
As a side note, whether this opens the link a new window or new tab is dependent on the browser and browser settings.
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