[英]jquery at caret plugin doesn't work in IE
I implement very big script logic using jquery plugin at caret(http://code.google.com/p/jquery-at-caret/), but now when I finish it I realized that it only works in Firefox and Chrome, it doesn't work in Internet Explorer. 我在caret(http://code.google.com/p/jquery-at-caret/)上使用jquery插件实现了很大的脚本逻辑,但是现在当我完成它时,我意识到它仅适用于Firefox和Chrome,在Internet Explorer中不起作用。
I realized that function "setCaretPosition" is that which is not working in IE. 我意识到函数“ setCaretPosition”是在IE中不起作用的函数。
I am getting only in IE "o is undefined", you can see in code snippet below that this is occurring from 79-89 lines of plugin code, but I can't figure it out how to fix this. 我只在IE中看到“ o is undefined”,您可以在下面的代码片段中看到这是从79-89行的插件代码中发生的,但是我不知道该如何解决。
I create very small code snippet to just replicate this bug: http://www.mediafire.com/?xxt0medyci61690 我创建了非常小的代码段来复制此错误: http : //www.mediafire.com/?xxt0medyci61690
I have modified the code in the plugin 我已经修改了插件中的代码
setCaretPosition: function(pos) {
var f1, f2, o;
o = this[0];
if (o.setSelectionRange) {
o.focus();
return o.setSelectionRange(pos, pos);
} else if (o.createTextRange) {
f1 = function () {
return o.focus();
};
setTimeout(f1, 10);
f2 = function() {
var range;
range = o.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
return range.select();
};
setTimeout(f2, 20);
return pos;
}
}
Please check, I have tested in IE8, IE9 & Firefox. 请检查,我已经在IE8,IE9和Firefox中进行了测试。
The function f(o, pos) is causing the issue. 函数f(o,pos)引起了问题。 Try to make individual functions and then call them.
尝试制作单个功能,然后调用它们。 There are two functions define with same name
f
. 有两个具有相同名称
f
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.