1

I want to trigger an event when a user pastes.

I have a contenteditable div and when the user pastes I want to capture the event and then focus back into the contenteditable div at the end of the paste which does not happen by default.

Ideas?

Thanks

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012

2 Answers2

1

I do not know, if this works cross-browser, it's working in Chrome:

$('body').bind('paste',function(){alert(1)});
topek
  • 18,609
  • 3
  • 35
  • 43
  • 1
    For the cross-browser support I found an article on quirks mode: http://www.quirksmode.org/dom/events/cutcopypaste.html – topek Oct 23 '11 at 21:39
1

You can bind to the 'paste' event -

jQuery(document).bind('paste', function(e){ alert('pasting!') })
ipr101
  • 24,096
  • 8
  • 59
  • 61