2 ms·
They're suggesting avoiding long-standing useful functionality because some people abuse it. There's no viable simple alternative to each of these methods, whi
by px1999 10y ago
They're suggesting avoiding long-standing useful functionality because some people abuse it. There's no viable simple alternative to each of these methods, which is _why_ they're in common use. They provide a reliable way to stop the user from interacting with the page until they've received a notification / provided a piece of data. onbeforeunload provides a way for a page to have the user ensure that data is saved before they navigate away. More importantly, they're one-liners.
No proposed alternative achieves these goals, and they definitely don't achieve them as simply or as elegantly. I understand switching alerts from app- to tab-modal, but when did the web become such a clusterfk of complexity? Not every page needs (or should need) to bring in their own dialog library, to save changes incrementally, or be concerned about users not accepting notifications before being able to provide important information to them.
This policy makes no sense because it recommends using ~10 lines of code which probably won't work for all your users in place of the 1 that definitely will. Telling people to avoid alert etc (by threatening to break the functionality in the future) just avoids actually solving the problem (which they could do) by taking away an incredibly useful and important piece of functionality.