Getting clipboard data using javascript?

I am using Html5 and JQuery.

<canvas style="border:1px solid grey;" id="cc" width="1000" height="800">
var pasteCatcher;
if (!window.Clipboard){
    pasteCatcher = document.createElement("div");
    pasteCatcher.setAttribute("id", "paste_ff");
    pasteCatcher.setAttribute("contenteditable", ""); = 'opacity:0;position:fixed;top:0px;left:0px;'; = "-20px";

        if(pasteCatcher.children.length == 1){
                        var canvas = document.getElementById("cc");
                         var ctx = canvas.getContext("2d");
            img = pasteCatcher.firstElementChild.src;
            var img2 = new Image();
            img2.onload = function(){
                ctx.drawImage(img2, 0, 0);
            img2.src = img;
            pasteCatcher.innerHTML = '';

Above code is working fine. When the clipboard has image then that will be set to canvas. IF the clipboard has text then how can i get the text and draw in canvas?



As you've discovered, access to the clipboard varies across browsers for security reasons.

Even the methods used to read/write the clipboard vary.

A workaround:

Have the users paste the text into an html textarea and then read the textarea value.

The benefits of the workaround are:

  • The user must paste somewhere anyway, so let that be the textarea.
  • The textarea can be edited by the user if they desire.
  • The textarea value is not restricted for security reasons, so it works cross-browser.

Need Your Help

1044 - Access denied for user 'root'@'%' to database 'test' cleardb

mysql navicat cleardb

I have an issue that when i try to connect to a database in cleardb it gives me this error:

Android Preference Textview Multiline?

android textview multiline preference

How can i use a Textview (Multiline) at a PreferenceActivity?