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
  • 103,298
  • 185
  • 610
  • 989

2 Answers2

1

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

$('body').bind('paste',function(){alert(1)});
topek
  • 17,966
  • 3
  • 34
  • 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
  • 23,772
  • 7
  • 57
  • 61