最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window.clipboardData.getData("Text") returns 0 in IE8 - Stack Overflow

programmeradmin0浏览0评论

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);

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);

Share Improve this question edited Jun 16, 2015 at 6:47 Aurelio 25.8k9 gold badges61 silver badges64 bronze badges asked Dec 1, 2010 at 20:24 08Hawkeye08Hawkeye 2462 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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.

发布评论

评论列表(0)

  1. 暂无评论