Re: Setting Editor.Text value when Editor block style is display:none in FireFox

  •  04-28-2009, 9:50 AM

    Re: Setting Editor.Text value when Editor block style is display:none in FireFox

    A bit more information...
     
    One might wonder why I would want to set the HTML of the editor before displaying it.  The answer, of course, is that I don't.  I want to set it immediately after displaying it...
    1. var div1=document.getElementById("div1");      
    2. div1.style.display="block";      
    3. var editor1 = document.getElementById('<%= Editor1.ClientID%>');      
    4. editor1.setHTML("test"); // throws the error      
    However, if I set a timeout of 1 second on the last line of code (defining editor1 globally of course), then it works perfectly... 
    1. var editor1;  // keep in global scope   
    2.   
    3. function setEditorHTML() {   
    4.     var div1=document.getElementById("div1");   
    5.     div1.style.display="block";   
    6.     editor1 = document.getElementById('<%= Editor1.ClientID%>');   
    7.     setTimeout("editor1.setHTML('test'), 1000);   
    8. }  
    So it's definitely a timing thing.  Apparently the editor doesn't instantiate itself, and hence make methods like setHTML available, until it is displayed.  This problem does not show up if you use the visibility style instead of display, but other problems do show up then that make that approach impractical.
     
    Aaron
View Complete Thread