← Back to context

Comment by privatelypublic

1 day ago

How do you do this? I'm looking to do it for the clipboard API. Browsers should be able to block copy and paste.

In firefox: about:config -> dom.disable_beforeunload=true

For copy-paste: dom.event.clipboardevents.enabled=false I would guess.

A quick google shows this for FF (taken from a thread in StackOverflow):

> In Firefox you can completely disable beforeunload events by setting dom.disable_beforeunload to true in about:config. Extensions may be needed for other browsers.

A word of caution: I'm not 100% sure, but I wonder if some web collaboration tools might use this to ensure data has been synced with a server.

  • It surely has a lot of legitimate uses, even if it is primarily abused. I’ve used it before to do various cleanup tasks, to have a more timely “user disconnected” event, rather than waiting on some timeout to occur server side.

    Having said that, it should never be the end of the world to disable, sites should never have data loss due to this event missing, because if so, they already have a data loss problem when for instance the power goes out.

    • I am not sure if this is implemented using this functionality but when I am on a console session on proxmox and hit ctrl+w due to muscle memory, it's nice to have a warning telling me the tab will be closed. Same with all kinds of remote access tools. One legit use case I can think of.