Reputation: 35346
This is an example DIV where when selected and paste (CTRL
+V
) it will paste a text or image on the div:
<div contenteditable="true" id="capture" style="height: 100px; width: 100px; "
onpaste='handlepaste(this, event)'></div
The problem here is my application will hide this div
and essentially user cannot find where it is located. So is there a way that paste event is triggered and that the text or image gets pasted on this div even not selected in the page?
Update:
What I mean, I will make the div hidden for a reason that I don't need my app to display the image or text being captured. It just need it to get the captured image or text later.
Upvotes: 0
Views: 4293
Reputation: 803
If your div doesn't contain anything initially then its will not appear. so you can do either of the following :
as default textonpaste='handlepaste(this, event)'
on outer div and insted of this you can pass the target div id or you can handle the target inside the handlepaste method.like
function handlepaste(event){ var target = $('#capture'); ...... }
Upvotes: 1