2012-08-13 92 views

回答

0

這是可能的,但需要一些知識。

您需要調用類似

self.switchStyle(url, ed); 

其中switchStyle是

// url is the url to the stylesheet file to be added to the editor iframes head 
    // ed is the editor object or editor id 
    switchStyle: function(url, ed) { 

     if (typeof ed != 'object') { 
      ed = tinymce.get(ed); 
     } 

        //replace the custom content_css if set 
     var url_to_replace = ed.getParam('content_css'); 

     var doc = ed.getDoc(); 
     var $doc = $(doc); 

     var sheets_urls = []; 

     if (url_to_replace){ 
      sheets_urls.push(url_to_replace); 
     } 

     // remove all stylesheets from sheets_urls 
     $doc.find('link').each(function() { 
      if (tinymce.inArray(sheets_urls, $(this).attr('href').split('?')[0]) !== -1) { 
       $(this).remove(); 
      } 
     }); 

     var link = doc.createElement('link'); 
     link.type = 'text/css'; 
     link.rel = 'stylesheet'; 
     link.href = url; 

     // setstylesheet 
     $doc.find('head:first').append(link); 
    }, 
相關問題