Paste event in Javascript

后端 未结 4 1089
礼貌的吻别
礼貌的吻别 2020-12-28 14:44

How can I handle the paste selected through right click in javascript? I tried with \"onpaste\" event and all other html events available but nothing works.

4条回答
  •  感动是毒
    2020-12-28 15:19

    I was surprised question #4532473 got closed unanswered about what happens if you want to capture the afterpaste event. As this is probably the problem half of the cases a possible approach in firefox (tested) is to register an oninput event right inside the onpaste handler and remove the oninput handler as soon as it's done executing.

    In ie the onpropertychange should be used instead of oninput. (not tested)

提交回复
热议问题