Kendall
Kendall

Reputation: 41

Why wont IE fire on paste event?

I need help figuring out why Internet Explorer won't fire my 'paste' event.

I'm using IE 11. Here is my code:

$(document).on('paste', '.pasteTarget', handlePaste);

When trying this in IE, the function never gets called. It works in chrome.

Upvotes: 4

Views: 2032

Answers (2)

Adrian Ber
Adrian Ber

Reputation: 21360

You could use beforepaste event instead and access clipboardData from window, not from the event. But, indeed as pointed out already, Clipboard API doesn't seem to be supported in IE: https://developer.microsoft.com/en-us/microsoft-edge/platform/status/clipboardapi/

Upvotes: 0

TimoStaudinger
TimoStaudinger

Reputation: 42460

Different browsers treat onpaste differently, or not at all. For IE 11, the latter seems to be the case.


From MDN:

Non-Standard

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Source


Edit: As pointed out in the comments, IE 11 does indeed support onpaste to some extent. However, as this is a non-standard feature, you should be careful about using it in production.

Upvotes: 2

Related Questions