Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent a script from closing the window/tab in Chrome?

I'm debugging an SSO app and I need to prevent the window from closing so I can inspect the requests and responses. I tried to disable Javascript but the login flow requires Javascript. Network > Preserve Log doesn't work either. Pinning the tab didn't work either. There are several redirects before it closes. I do not have access to the code of the SSO server. How can I prevent a script from closing the window?

like image 568
Chloe Avatar asked Aug 31 '18 00:08

Chloe


People also ask

How do I stop Chrome from closing my tabs?

Use the Pin tab option to keep Prevent Close available in Chrome. To make this as painless as possible, I recommend pinning this website to your browser then moving the tab out of the way. To do that open Prevent Close, and then right-click the tab with your mouse. From the context menu select Pin tab.

How do I stop a browser window from closing?

Answers. There is no way to prevent a user from closing HIS browser. All you can do is display a message, as Jagan posted, but that won't prevent them from closing their browser if they ignore your message.

How do you resolve Scripts may close only the windows that were opened by them?

Scripts may close only the windows that were opened by it. A workaround now is redirect user to another page rather than close the window, you could redirect user to a notification page to show "The items has been closed successfully" using window. location.

How do you keep a tab open when typing?

All you need to do is select the window and then hit 'Ctrl + Space' from your keyboard, and the window will stay there as it is on top of all other windows.


1 Answers

I was able to do it by opening the link in an Incognito Window. When it tried to close itself, Chrome gave the warning

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

enter image description here

I didn't have a script open the window in the first place. Instead I was using target="_blank", but Chrome may have equated that with a script. (window.opener was set.)

like image 187
Chloe Avatar answered Nov 15 '22 11:11

Chloe