2

<a href='.$login.' target ="_blank" onclick="window.close();"><i class="fa fa-sign-in f-s-25" style="margin-left: 10px;"></i></a>

In laravel controller I am using tag in which on button click window.close() is working well, but when i restart my server or my PC then after it is not working.

Please give me a solution for how to close the current tab in tag in the Laravel controller without using Javascript. Window.close() is not working in also firefox.

sweta ramani
  • 31
  • 1
  • 4

1 Answers1

0

I tried your code and got the below error that means If your script did not initiate opening the window (with something like window.open), then the script in that window is not allowed to close it. Its a security to prevent a website taking control of your browser and closing windows.

"Scripts may close only the windows that were opened by it."

Sehdev
  • 5,486
  • 3
  • 11
  • 34
  • what is the other solution if i want to close tab in controller..?? – sweta ramani Feb 20 '20 at 13:06
  • @swetaramani The window which has the link can not be closed by Javascript. Why do you want to do that? You can simply remove target ="_blank" from link and open it in the current window instead opening in new tab. – Sehdev Feb 20 '20 at 13:12
  • actually in my project admin can login as a store user. i want that after login as a storeuser admin can not go back from browser therefor i want open new tab and close current tab so no any back path is there for go back in new tab. – sweta ramani Feb 20 '20 at 13:29
  • you can open window in current tab & use this script to disable back button of browser. – Sehdev Feb 20 '20 at 14:09
  • can I use this script in the controller..?? actually I am learning laravel so I don't know how to use a script in laravel. – sweta ramani Feb 21 '20 at 12:51
  • thanks for your reply but still there is back history in browser. – sweta ramani Feb 21 '20 at 13:30