Quantcast
Channel: How do I get the URL for a dropped image using a Chrome userscript? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How do I get the URL for a dropped image using a Chrome userscript?

$
0
0

In the following chrome user script, how can I get a url for an image that I drag from my desktop?Where I have the debugger line, I'm getting the empty string for e.dataTransfer.getData("text") and e.dataTransfer.getData("url")

// ==UserScript==// @match http://*/*// @match https://*/*// ==/UserScript==function preventDrag(e) {  e.stopPropagation();  e.preventDefault();}function handleDrop(e) {  console.log("Just dropped: "+ e.dataTransfer.files[0].name);  debugger  // TODO: grab the url for e.dataTransfer.files[0]  e.stopPropagation();  e.preventDefault();}document.addEventListener('drop', handleDrop, false);document.addEventListener('dragenter', preventDrag, false);document.addEventListener('dragover', preventDrag, false);

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images