DEV Community

Discussion on: Always double-check what you copy from websites

Collapse
 
ruudje profile image
Ruud Schroën • Edited

Yes, oncopy is the HTML equivalent.

Reading is only possible within a paste event.

Collapse
 
baenencalin profile image
Calin Baenen

Is it possible in a copy event, or no?
If so, do you know why they made the decision to leave out reading from copying events?

Thread Thread
 
ruudje profile image
Ruud Schroën • Edited

According to Mozilla docs, reading is not possible within the copy event. As for why it's disabled, I think the content is written to the clipboard AFTER the event is finished, because in order to change the clipboard data you need to cancel the events default action. So if you could read within the copy event, you would be able to read the old clipboard data, which is a security issue. I don't have any sources that confirm this however.

There is a way for websites to read the clipboard, which involves using the navigator. But if a website tries to do this, you will get a popup asking you for permission.