本文介绍了如何使用JavaScript检测鼠标右键+粘贴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法检测右键点击,然后在IE和Firefox上粘贴JavaScript?
Is there a way to detect a right click followed by paste with JavaScript on IE and Firefox ?
更新:
我决定用Jquery来做这件事:
I decided to use Jquery to do it:
$('#controlId').bind('paste', null, function() {
// code
});
这不完全是我所期待的(因为它在'ctrl + v'以及它上面被触发了在'右键单击+粘贴'但我可以解决它。
It's not exactly what I was looking (because it gets fired on 'ctrl + v' as well as in 'right click + paste' but I can work around it.
在Chrome,Firefox 3,IE 7和IE 6上测试它并且它正在工作
Tested it on Chrome, Firefox 3, IE 7 and IE 6 and it's working
推荐答案
使用IE浏览器你有onpaste
With IE you have onpaste
使用Mozilla你可以查看
oninput
和
With Mozilla you can look intooninputand
elementReference.addEventListener("DOMCharacterDataModified", function(e){ foo(e);}, false);
没有简单的解决方案。
Eric
这篇关于如何使用JavaScript检测鼠标右键+粘贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!