tags:

views:

271

answers:

3

I have inputbox. When page load, i use mouse to right click inputbox and choose paste from contextmenu.

when text get pasted, which event to use to alert text instantly as soon as paste happens?

i use "input paste" but not work in IE

A: 

The way I saw this issue got solved is the following:

It was set an action with setInterval (javascript function), which checks every 200ms the content of input. If it is changed then the past or typing occurred.

Jenea
+4  A: 

You can bind these events like so:

    $(document).ready(function() {
        $("#Text1").bind('copy', function(e) {
            alert('copying text!');
        });
        $("#Text1").bind('paste', function(e) {
            alert('pasting text!');
        });
        $("#Text1").bind('cut', function(e) {
            alert('cut text!');
        });
    });
Buggabill
+1 I was too slow.
Tester101
+1  A: 

A hack that would work most of the time would be to hook into the control's onchange while also storing the control's initial text in a separate variable. Any time the length of the new text is longer than the original text by more than one character, you can assume that something was pasted in. Obviously this wouldn't work if someone pasted in a one-character string, but people don't do that very often.

MusiGenesis
What a horrible idea. It's a damn good thing you don't do much web work anymore.
MusiGenesis