EXTJS怎么判断光标在文本框内???并以对话框的形式添加一句话至光标处???

var btn = new Ext.Button({

        text: 'insert',

        renderTo: document.body,

        handler: function() {

            var o = Ext.getDom('sub'); //The text box to be inserted

            o.focus();

            var s;  //以先保存选区的方式用于在IE中实现插入

            if (document.selection) {

                s = document.selection.createRange();

            } 

            Ext.Msg.prompt('Name', 'Please enter :', function(btn, text) {

                if (btn == 'ok') {

                    var value = text;

 

                    if (document.selection) {//用于IE

                        s.text = value;

                    }

                    else {//用于FF

                        o.value = o.value.substr(0, o.selectionStart) + value + o.value.substr(o.selectionEnd);

                    }

 

                }

            });

        }

    });

 

你可能感兴趣的:(EXTJS怎么判断光标在文本框内???并以对话框的形式添加一句话至光标处???)