How to select "Cancel" by default in the confirmation field when closing the browser tab

I know that this site has a very similar question ( JavaScript: how to select "Cancel" by default in the confirmation field? ), But I felt I didn’t get a good answer from this, because my rooms do not match.

Description of the problem:. I am writing a Javascript popup in a web browser that should accept some information as input, and the user can choose between “OK” to process the information and continue with anything, or “Cancel” to close the window and return to what whatever. So far, so good. The problem is that some users click the “X” in the upper right corner of the pop-up window to close the window (by mistake or actually believing that the data has been processed) and get a second pop-up dialog box (you cannot change the text in this dialog box) displaying "Are you sure you want to go from this page?" - "Click" OK "to continue, or" Cancel "to stay on the current page" - OK / Cancel ...Now, some users simply press the enter key on their keyboard, and the pop-up window closes and all information is lost.

Question: Can you, or is there a workaround, set the focus to "Cancel" instead of "OK" when it comes to whether to close the Internet Explorer popup / tab or not

Thank you in advance! =)

+5
source share
1 answer

Unfortunately, I do not think that it is possible to change the focus to dialog boxes created by the browser.

As Deestan suggested, perhaps you can create a fake popup using js and css and do whatever you want, in terms of styling it, and still enter user information and pass the information into your code.

From what I've heard / read, it is generally accepted that using alert () or popup () for anything other than debugging is disapproving.

+3
source

All Articles