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