detect paste on input box

前端 未结 4 1275
挽巷
挽巷 2020-12-14 21:34

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 insta

4条回答
  •  攒了一身酷
    2020-12-14 22:09

    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.

提交回复
热议问题