Question

I need google translate with my clipboard. so I make some bookmarklet with javascript. but I can't find solution for get data from clipboard.

searching stackoverflow, i find some question using window object and clipboardData.

but chrome has not clipboardData method.

my idea is copy translate source and click bookmarklet( location.href to https://translate.google.co.kr/ and copy clipboard content to textarea#source)

but I don't know how can I access clipboard using javascript.

below my skeleton codes..

  var test = function(){
    changeLocation();
    var content = getClipbord();
    setSource(content);
    };

  var changeLocation = function(){
    location.href="https://translate.google.co.kr/";
  };

  var getClipbord = function(){
    return "";
  };
  var setSource = function(content){
  };
  test();
Was it helpful?

Solution

If you could access clipboard from JavaScript, it would be a huge security hole.

What you can do with a bookmarklet (and what bookmarklets usually do) is just to pull the selection you marked (without using clipboard at all).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top