2013-05-10 206 views
1

使用TinyMCE作爲回覆郵件表單。光標應自動着陸在文本條目中。我用auto_focus:true,但它不起作用。 Plz的幫助。TinyMCE auto_focus不起作用

我的代碼:

<script type="text/javascript"> 
tinymce.init({ 
    selector: "textarea.tmce", 
    theme: "modern", 
    auto_focus:true, 
    plugins: [ 
     "advlist autolink lists link image charmap print preview hr anchor pagebreak", 
     "searchreplace wordcount visualblocks visualchars code fullscreen", 
     "insertdatetime media nonbreaking save table contextmenu directionality", 
     "emoticons template paste" 
    ], 
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image", 
    toolbar2: "print preview media | forecolor backcolor emoticons", 
    templates: [ 
     {title: 'Test template 1', content: 'Test 1'}, 
     {title: 'Test template 2', content: 'Test 2'} 
    ], 
}); 
</script> 

回答

0

你可以使用這樣的事情

tinyMCE.init({ 
    ... 
    setup : function(ed) { 
     ed.onInit.add(function(ed) { 
      ed.focus(); 
     }); 
    } 
}); 
+0

 well thanks Thariama for your answer. well, in fact it worked with the line: tinymce.init({ .... auto_focus: "id_of_textarea", .... 
2013-05-31 11:45:39

0

的auto_focus屬性應包含要注重項目的ID。

auto_focus:該選項可讓您自動對焦編輯器實例。 這個選項的值應該是一個編輯器實例ID。編輯器實例ID是 替換原始textarea或div元素的id。

我已經看到IE7 +拋出js錯誤,如果你有auto_focus設置爲true,而不是textarea或div的ID。

+0

看起來像auto_focus:在代碼中檢查true,並正確設置編輯器。對我來說,elementID沒有像記錄的那樣工作。 – 2016-03-11 14:30:02