问题
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.
回答1:
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>
回答2:
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.
来源:https://stackoverflow.com/questions/33913461/laravel-redirect-to-a-new-tab