Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TextArea maxLength使用javascript在firefox中不起作用_Javascript_Html - Fatal编程技术网

TextArea maxLength使用javascript在firefox中不起作用

TextArea maxLength使用javascript在firefox中不起作用,javascript,html,Javascript,Html,当用户在文本框中粘贴文本时,onpaste=doPaste事件处理程序在IE10中工作正常, 但不能在Firefox中工作 代码:e=事件 我遗漏了任何内容..或者有跨浏览器修复程序吗?Try var sData=e.clipboardData | | window.clipboardData.getDataText可能重复 function doPaste(e) { maxLength = 500; value = document.getElementById("<%=

当用户在文本框中粘贴文本时,onpaste=doPaste事件处理程序在IE10中工作正常, 但不能在Firefox中工作

代码:e=事件

我遗漏了任何内容..或者有跨浏览器修复程序吗?

Try var sData=e.clipboardData | | window.clipboardData.getDataText可能重复
function doPaste(e) {
    maxLength = 500;
    value = document.getElementById("<%=txtTitle.ClientID%>").value;        
    if (maxLength) {
        if (e.preventDefault)
            e.preventDefault();
        else
            e.returnValue = false;            
        var oTR = document.selection.createRange();
        var iInsertLength = maxLength - value.length + oTR.text.length;
        var sData = window.clipboardData.getData("Text").substr(0, iInsertLength);
        oTR.text = sData;
    }
}