为什么 IE 不会在粘贴事件上触发? [英] Why wont IE fire on paste event?

查看:32
本文介绍了为什么 IE 不会在粘贴事件上触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助弄清楚为什么 Internet Explorer 不会触发我的粘贴"事件.

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

我使用的是 IE 11.这是我的代码:

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

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

在 IE 中尝试此操作时,该函数永远不会被调用.它适用于 chrome.

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

推荐答案

不同的浏览器对 onpaste 的处理不同,或者根本不处理. 对于 IE 11,后者似乎就是这样.

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

来自 MDN:

非标准

此功能是非标准的,不在标准轨道上.不要在面向 Web 的生产站点上使用它:它不适用于每个用户.实现之间也可能存在很大的不兼容性,未来可能会改变行为.

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.

来源

正如评论中所指出的,IE 11 确实在某种程度上支持 onpaste.但是,由于这是一项非标准功能,因此在生产中使用它时应小心.

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.

这篇关于为什么 IE 不会在粘贴事件上触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆