DOM

Window:paste イベント

 編集:2022.10.18 by T.A.

[Edge]。→

ウインドウ内でユーザーがブラウザーのユーザー インターフェイスから“貼り付け”操作を実行したときに発生します。

バブリング あり
キャンセル可能 はい
インターフェイス ClipboardEvent
イベント ハンドラー プロパティ onpaste¶

Element:paste イベント。

copy、cut、paste イベント

HTML:

<SPAN id=IdLog></SPAN>

JavaScript:

function JobCopy(eve){  //copy イベントの処理:
  D=eve;  //=[object]:[object ClipboardEvent]。「JavaScript:」の一部を範囲指定して [Ctrl]+[C] をした。
詳細 //isTrusted=[boolean]:true //clipboardData=[object]:[object DataTransfer] //type=[string]:copy //target=[object]:[object HTMLTableCellElement] //currentTarget=[object]:null //eventPhase=[number]:0 //bubbles=[boolean]:true //cancelable=[boolean]:true //defaultPrevented=[boolean]:false //composed=[boolean]:true //…
IdLog.innerHTML=IdLog.innerHTML+"copy "; } function JobCut(eve){ //cut イベントの処理: D=eve; //=[object]:[object ClipboardEvent]。「JavaScript:」の一部を範囲指定して [Ctrl]+[X] をした。
詳細 //isTrusted=[boolean]:true //clipboardData=[object]:[object DataTransfer] //type=[string]:cut //target=[object]:[object HTMLTableCellElement] //currentTarget=[object]:null //eventPhase=[number]:0 //bubbles=[boolean]:true //cancelable=[boolean]:true //defaultPrevented=[boolean]:false //composed=[boolean]:true //…
IdLog.innerHTML=IdLog.innerHTML+"cut "; } function JobPaste(eve){ //paste イベントの処理: DA=eve; //=[object]:[object ClipboardEvent]。「JavaScript:」の一部を範囲指定して [Ctrl]+[V] をした。貼り付けできない場所であるが。
詳細 //isTrusted=[boolean]:true //clipboardData=[object]:[object DataTransfer] //type=[string]:paste //target=[object]:[object HTMLTableCellElement] //currentTarget=[object]:null //eventPhase=[number]:0 //bubbles=[boolean]:true //cancelable=[boolean]:true //defaultPrevented=[boolean]:false //composed=[boolean]:true //…
IdLog.innerHTML=IdLog.innerHTML+"paste "; } //window.oncopy=JobCopy; //イベント割り当て。 //window.oncut=JobCut; //イベント割り当て。 //window.onpaste=JobPaste; //イベント割り当て。 window.addEventListener('copy', JobCopy); window.addEventListener('cut', JobCut); window.addEventListener('paste', JobPaste);

oncopy、oncut、onpaste が働かない。

clipboardDataDataTransfer


テスト