Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138221

How to get images src link in javascript using context menu in chrome?

$
0
0

I'm trying to get the images src URL and add an "" tag to it using JS and a chrome context menu. I'm new to JS and coding in general and was wondering if I'm on the right track.

chrome.contextMenus.create({
  title: "Copy and add <img src>", 
  contexts:["image", "link"],
  onclick:copyToClipboard
  });


function copyToClipboard(info){
    var srcURL = "<img src=\""+info.srcUrl+"\">";
    srcURL.select();
    document.execCommand('copy', false, null);
}

Right now it doesn't do anything.. I get an error saying select() is not a function. 🤔


Viewing all articles
Browse latest Browse all 138221

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>