使用jQuery检测浏览器中的上下文菜单粘贴 [英] Detecting a context-menu paste in the browser with jquery

查看:109
本文介绍了使用jQuery检测浏览器中的上下文菜单粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当有人通过右键单击将内容粘贴到文本区域时,我试图检查文本区域中的文本长度.

I am trying to check the length of the text in a textarea when someone pastes content in there via the right-click but can't seem to find how to do it.

推荐答案

$('textarea').bind('paste', function() {
    var that = this;
    setTimeout(function() {
        var length = that.value.length;
        alert(length);    
    }, 0);

});

实时演示: : http://jsfiddle.net/4UrE3/1 /

可在Firefox 3.6,Chrome,Safari和IE9 beta中使用. 在Opera中不起作用.

Works in Firefox 3.6, Chrome, Safari and IE9 beta. Does not work in Opera.

这篇关于使用jQuery检测浏览器中的上下文菜单粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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