News for hackers. Stuff that matters.
Re:Ask HN: Why do browsers still support pop up dialogs and ... by aboodman on Saturday May 21, 2016 @01:15PM (#11745361)
It's not possible to prevent applications from creating modal dialogs and still allow them to be usefully interactive. If you took away `alert` and friends, sites would (and do) just create dialogs with HTML instead.

If you want websites to be able to be dynamic at all, then they can use that power to be annoying. Two sides of the same coin.

(the history thing seems like it might be more addressable)

Re:Ask HN: Why do browsers still support pop up dialogs and ... by twshoopboop on Saturday May 21, 2016 @01:19PM (#11745376)
Except my point is I'm completely okay with this because its not modal at an application level if its HTML. I just want to be able to leave the site. Change the way the page is rendered all you want, disable interactivity etc but I don't feel a website should be able to prevent me from closing it which is what a modal dialog does.
Re:Ask HN: Why do browsers still support pop up dialogs and ... by bryanlarsen on Saturday May 21, 2016 @01:42PM (#11745465)
The most common use for onwindowunload dialog boxes is to warn the user of unsaved changes and prevent their loss.

Our web app autosaves so the dialog box should never appear, but our metrics show that it appears surprisingly often -- sometimes it can take a few seconds for changes to flush through the websocket, and for the save to get acknowledged.

If you took that away, our users would lose changes. I imagine they would get pretty irate.

Re:Ask HN: Why do browsers still support pop up dialogs and ... by jessriedel on Saturday May 21, 2016 @01:51PM (#11745492)
If this is absolutely necessary, you can force the site to request permission to do this, just like getting location.
Re:Ask HN: Why do browsers still support pop up dialogs and ... by globuous on Saturday May 21, 2016 @04:54PM (#11746145)
How about making it 'harder' for the user to close the browser when there is an alert being shown by a website ? For instance, if google docs throws an alert about the data not being saved, your browser could throw you a msgbox notifying you that such tab has an alert you haven't dealt with when you try to close it.

Yes, that's a lot of msgboxes, but it's a decent compromise I think. It's not like that would happen very often anyway.

Re:Ask HN: Why do browsers still support pop up dialogs and ... by bryanlarsen on Saturday May 21, 2016 @02:13PM (#11745568)
Google docs and Gmail and many other top 100 sites use on window unload. It wouldn't fly.
Re:Ask HN: Why do browsers still support pop up dialogs and ... by dredmorbius on Sunday May 22, 2016 @12:05AM (#11747340)