laravel redirect to a new tab

旧街凉风 提交于 2019-12-08 19:08:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!