Shaokan
Shaokan

Reputation: 7684

capture paste event / pasted html - javascript

I'd like to capture the pasted html in both mozilla and ie and then, before the paste event occurs, I'd like to modify it. Any suggestions?

Upvotes: 5

Views: 7972

Answers (2)

Viral Jain
Viral Jain

Reputation: 1014

Here's a small - neat - jQuery snippet for the capturing Cut/Copy/Paste events:

$("#Text1").bind('cut copy paste', function(e) {
    alert(e.type + ' text!'); //Alerts the Cut/Copy/Paste event        
});

Source: http://www.devcurry.com/2009/07/detect-copy-paste-and-cut-operations-on.html

Upvotes: 2

Tim Down
Tim Down

Reputation: 324477

You can do it, but it's hacky. You have to essentially redirect the paste to an off-screen element. Here's my answer to a similar question: JavaScript get clipboard data on paste event (Cross browser)

Upvotes: 4

Related Questions