Reputation: 35282
This is the code that throws the error, not sure why, it used to work with Chrome. I'm using Chromium now and its throwing the error Uncaught TypeError: Cannot read property 'length' of undefined
$wnd.addEventListener("paste",processEvent);
function processEvent(e) {
if (e.clipboardData && e.clipboardData.getData) {
console.log("clipboard from event"); // can see in console log
var items = e.clipboardData.items;
if(items.length == 0){ // error here
}
}
}
So it seems that the problem is var items
is undefined
Upvotes: 1
Views: 3622
Reputation: 1943
I would check if the items
is defined first
$wnd.addEventListener("paste",processEvent);
function processEvent(e) {
if (e.clipboardData && e.clipboardData.getData) {
console.log("clipboard from event"); // can see in console log
var items = e.clipboardData.items;
if(items != undefined && items.length == 0){ // error here
}
}
}
But you cannot read or set clip board data in JavaScript
Upvotes: 1