2010-11-10 39 views
12

Tôi đã thử một số phương pháp để thiết lập chiều rộng của vùng văn bản tinymce.Làm thế nào để thiết lập chiều rộng của textarea sử dụng tinymce?

nỗ lực 1 của tôi:

height: '200px', 
width: '220px' // inside tinyMCE.init({ 

Trong nỗ lực thứ 2:

<textarea name="editorial" cols="40" rows="20" id="editorial" style="width: 40em; height: 20em"><?=$row['editorial']?></textarea> 

Nhưng vẫn còn, tôi không thể để có được chiều rộng theo yêu cầu của tôi.

Bạn có ý tưởng nào không?

+0

Bạn có thể đưa ra ví dụ về những gì bạn đã thử –

Trả lời

20

Tôi nghĩ rằng vấn đề có thể với các thanh công cụ chức năng TinyMCE init của bạn.

Hãy thử ví dụ này và cho tôi biết nếu nó phù hợp với bạn?

trong HTML của bạn:

<textarea name="editorial" class="test" cols="40" rows="20" id="editorial" > editorial</textarea> 

sau đó sử dụng tinyMCE.init này trong JavaScript:

tinyMCE.init({ 
     // General options 
     mode: "textareas", 
     theme: "advanced", 
     width: "300", 
     height: "200", 

     // Theme options 
     theme_advanced_buttons1: "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull", 
     theme_advanced_buttons2: "", 
     theme_advanced_buttons3: "", 
     theme_advanced_buttons4: "", 
     theme_advanced_toolbar_location: "top", 
     theme_advanced_toolbar_align: "left", 
     theme_advanced_resizing: false, 

    // Selector 
     editor_selector: "test", 

}); 

Điều này làm việc cho bạn?

1

Điều thú vị là chiều rộng và độ sâu đang được đặt trong thuộc tính kiểu của khung nội tuyến.

gì tôi làm để thiết lập chiều rộng của tôi theo thiết lập init của tôi là để thay đổi thuộc tính phong cách của iframe:

// ed is the editor instance 
var frameid = frameid ? frameid : ed.id+'_ifr'; 

// get iframe 
var current_iframe = document.getElementById(frameid); 

if (current_iframe && !window.opera){ 

    styles = current_iframe.getAttribute('style').split(';'); //width and heigth 
    for (var i=0; i<styles.length; i++) { 
    // case width setting is found - remove it 
    if (styles[i].search('width:') == 1){ 
     styles.splice(i,1); 
     break; 
    } 
    current_iframe.setAttribute('style', styles.join(';')); // write styles back to the iframe 
    current_iframe.width = ed.getParam('width'); // set the width i already set in the configuration 
} 
11

Bạn có thể sử dụng cách này ..

tinymce.init({ 
selector: "textarea", 
plugins: [ 
      "advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker", 
      "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking", 
      "table contextmenu directionality emoticons template textcolor paste fullpage textcolor" 
    ], 

    toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect", 
    toolbar2: "cut copy paste | bullist numlist | outdent indent blockquote | undo redo | anchor | forecolor backcolor", 


    menubar: false, 
    toolbar_items_size: 'small', 

    height: "100", 
    width:500, 

}); 

Nếu bạn muốn thiết lập chiều rộng sau đó chỉ cần thêm width: 300

Lưu ý: Không sử dụng qoutes đơn hoặc kép như width: '300' hoặc chiều rộng: "300"

+0

Bạn không cần phải bao gồm tên của mình làm chữ ký trong bài đăng của mình. Của nó đã có. –

+0

Cảm ơn bạn đã gợi ý Sanjeev .. –

+1

Cảm ơn bạn đã lưu ý rằng bạn đã thêm, nó mang lại cho tôi giải pháp –

Các vấn đề liên quan