Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.clipboardData.getData("Text") returns 0 in IE8

I'm trying to implement maxlength on a textarea. In IE7, window.clipboardData.getData("Text") returns the correct number of characters copied. in IE8, the same call returns 0. What's wrong?

here is the js

var someRule= {
  "textarea" : function(element) {
    element.onpaste = function() {
      var copied = window.clipboardData.getData("Text");
      alert('copied length = '+copied.length);
    }
  }
};

Behaviour.register(someRule);

alt text

like image 675
08Hawkeye Avatar asked Dec 01 '10 20:12

08Hawkeye


1 Answers

There is a security setting in IE8:

To prevent a web site from reading your clipboard, take the following steps:

Go to Tools->Internet Options. Click on the Security Tab. Click on "Custom Level." Scroll down to the Scripting section under Settings. Set "Allow paste operations via script" to Disable or Prompt. Press the OK buttons to close the dialog boxes.

In your case, this setting is probably disabled.

like image 171
Evan Mulawski Avatar answered Oct 23 '22 09:10

Evan Mulawski