I've stumbled upon a strange issue and I have two questions: 1) is it a bug in browsers` implementation (checked in Chrome, Firefox, Safari)?; 2) is there a workaround available?
Steps to reproduce:
And here's the results:
The last case is the one I'm wondering about. Why targeting Cancel button with an enter key is equal to hitting OK button? I haven't found any hint in the spec: https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-confirm
This is a standard UI convention for Yes/No dialog boxes that should be consistent across your operating system. It is nothing specific to JavaScript prompts.
Space activates the focused button.
Enter actives that default button.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.