Php 铬合金TinyMce焦点

Php 铬合金TinyMce焦点,php,javascript,jquery,focus,tinymce,Php,Javascript,Jquery,Focus,Tinymce,我对chrome和tinymce有意见。要在编辑器中设置焦点,我需要执行以下操作: tinyMCE.getInstanceById('my_editor_id').focus(); 它在FF和IE中工作良好。为什么不在chrome中工作 这根本不起作用: tinymce.execCommand('mceFocus', false, 'my_editor_id'); 还有其他建议吗?试试以下方法: setup: function(ed){ ed.onInit.add(function(e

我对chrome和tinymce有意见。要在编辑器中设置焦点,我需要执行以下操作:

tinyMCE.getInstanceById('my_editor_id').focus();
它在FF和IE中工作良好。为什么不在chrome中工作

这根本不起作用:

tinymce.execCommand('mceFocus', false, 'my_editor_id');
还有其他建议吗?

试试以下方法:

setup: function(ed){
   ed.onInit.add(function(ed){
      $(ed.getDoc()).contents().find('body').focus(function(){tinymce_focus();});
   });
}

以下解决方案对我有效。我创建了一个焦点事件监听器,它可以引起焦点。我不确定这是否创建了一个无限循环,但它工作起来没有任何问题

// Chrome Hack
var addEvent = function(node,eventName,func){

      if ("undefined" == typeof node || null == node) {              
      } else {
          if (!node.ownerDocument.addEventListener && node.ownerDocument.attachEvent) {
              node.attachEvent('on' + eventName, func);
          } else node.addEventListener(eventName,func,false);
      }
}; 

var cur = ed.dom.select('textarea'); // select all tinymce textareas
for(var idx=0;idx<cur.length;idx++) {           
    addEvent(cur[idx],'focus',function(evt) {
            evt = evt ? evt : window.event;                             
            evt.target.focus();
            return true;                                
        });
}
//Chrome黑客
var addEvent=函数(节点、事件名、函数){
如果(“未定义”==typeof节点| | null==node){
}否则{
if(!node.ownerDocument.addEventListener&&node.ownerDocument.attachEvent){
node.attachEvent('on'+eventName,func);
}else node.addEventListener(eventName,func,false);
}
}; 
var cur=ed.dom.select('textarea');//选择所有tinymce文本区域
对于(var idx=0;idxI think
focus()
在Chrome中不受正确支持。我建议在使用click()时使用
click()
,出现以下错误:未捕获类型错误:对象[Object Object]没有方法“click”