在Jquery中如何处理粘贴? [英] In Jquery How to handle paste?

查看:252
本文介绍了在Jquery中如何处理粘贴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复项:
如何处理jQuery中的oncut,oncopy和onpaste ?
jQuery捕获粘贴输入

Possible Duplicates:
How do you handle oncut, oncopy, and onpaste in jQuery?
jQuery catch paste input

我有一个文本区域,粘贴到我想要的文本区域上

I have a textarea, on paste to that textarea I want to

  1. 格式化粘贴值
  2. 附加到文本区域

可以用Java语言完成吗?

could that be done in Javascript?

推荐答案

有一个onpaste事件在现代浏览器中有效:

There is an onpaste event that works in modern day browsers:

$("#textareaid").bind("paste", function(){});

该事件的问题,它告诉您它将要发生,但没有提供您用户要粘贴的内容. JavaScript已限制对剪贴板的访问,默认情况下它被禁用.如果启用了访问权限,则可以读取剪贴板数据,然后对其进行操作.

Problem with the event, it tells you that it is about to happen, but it doesn't give you what the user is pasting. JavaScript has restricted acccess to the clipboard and by default it is disabled. If the access is enabled you can read the clipboard data and than manipulate it.

这篇关于在Jquery中如何处理粘贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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