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

Last post 05-07-2009, 6:15 AM by Kenneth. 12 replies.
Sort Posts: Previous Next
  •  05-10-2007, 10:46 AM 29484

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

    (originally posted in Cute Editor for ASP forum by accident -- sorry)

    I am trying to set the initial text of the editor to something from the database. The editor resides in a 'hidden' block until the user clicks on something to 'unhide' it.   I'll include the example at the bottom.

    Works fine in IE, but throws an error in FF. (Haven't checked other browsers.) The error *only* is thrown if the encompassing block is hidden. Take the 'display:none' out and we're good as gold.

    ----Begin Head----
    myEditor.Text = [[FromDataBase]]
    ----End Head----

    ----Begin Body----
    <a href="#" onClick="jsChangeStyleToBlock('DivEdit'); return false;">Show Editor</a>
    <div id="DivEdit" style="display:none;">
      <CE:Editor id="myEditor" runat="server"></CE:Editor>
    </div>

    ----End Body----

    ----Begin Error (Thx to FireBug)----
    uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMNSHTMLDocument.designMode]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: http://SITE/CuteEditor/Load.ashx?type=scripts&file=Gecko_Loader :: Ox87a :: line 3" data: no]
    ----End Error----

    Edit: Oh, btw, this worked fine before I upgraded us to the most recent version.

  •  05-10-2007, 2:45 PM 29511 in reply to 29484

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

    >>Edit: Oh, btw, this worked fine before I upgraded us to the most recent version.
     
    Do you mean it works fine in version 5.3 or 6.0 (ealier build)?
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  05-14-2007, 1:49 PM 29642 in reply to 29511

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

    According to CuteEditor.dll files - pulled directly from the dlls...

      Works fine: CuteEditor 5.3 Build 2006-08-18

      Error with: CuteEditor 6.0 Build 2006-04-23 (Assuming that the build date in the latter 'should' have been 2007-04-23...)

    Hope that's enough info, if not, let me know. Thx!!!
  •  05-25-2007, 9:17 AM 30117 in reply to 29642

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

    Since the last post, I've tried a few workarounds to test this, but the only thing that seems to work is removing the "style=display:none" from the div container around the Editor. Since we're producing multiples per page and only showing 1 at a time on request, we need that style or else we have to start putting each one on a different page (which wouldn't be optimal).

    Any ideas would be greatly appreciated.

  •  05-27-2007, 11:28 AM 30135 in reply to 30117

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

  •  05-28-2007, 6:25 PM 30172 in reply to 30135

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

    Forgive my possible ignorance here. Is there any special code or an update package that I may have missed from that link?
  •  05-29-2007, 1:31 PM 30201 in reply to 30172

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

    Please download the latest build and try again.
     
    Keep me posted
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  05-31-2007, 9:50 PM 30292 in reply to 30201

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

    This evening, I downloaded CuteEditor 6.0 Build 2007-05-21 (though I noticed that some files in this build were timestamped as today...).

    I'm no longer seeing this problem.

    Thanks!

  •  04-27-2009, 6:26 PM 51581 in reply to 30292

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

    I'm having the same problem, now with version 6.3.
     
    The first time you unhide the div with the Cute Editor in it (by setting display = block) it throws an error when you call Editor1.setHTML(myHTML);
     
    However all subsequent times I unhide the div, everything works fine. 
     
    I have a live demo, which illustrates the problem, here: http://bayareacareerpathways.org.previewdns.com/Initiatives.aspx.  Hover your mouse over any of the text in the main part of the page to see a context menu come up.  select the first item in the context menu to bring up the editor.
     
    BTW this problem doesn't exist if I use style.visibility to hide and show the div, instead of style.display.  The only problem with style.visibility is it seems to leave some "ghosts" behind after the editor div is hidden. 
     
    Thanks!
     
    BTW, I forgot to mention, this result is consistent in both Firefox 3 and IE7.  Thanks.
  •  04-28-2009, 7:45 AM 51605 in reply to 51581

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

    Hi Aaron,
     
    It works fine for me, please download the latest version and test the example below:
     
    Download:
     
     
    -------------------------------------------------------------->
     

    <%@ Page Language="C#" AutoEventWireup="True" %>

    <%@ Register Namespace="CuteEditor" Assembly="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <script>
    function show()
    {
    var div1=document.getElementById("div1");
    div1.style.display="block";

    }
    function hide()
    {
    var div1=document.getElementById("div1");
    div1.style.display="none";

    }
    function sethtml()
    {
    var editor1 = document.getElementById('<%= Editor1.ClientID%>');
    editor1.setHTML("test");
    }
    </script>

    <head id="Head1" runat="server">
        <title>DataList Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <input id="Button1" type="button" value="show" onclick="show()" />
            <input id="Button3" type="button" value="hide" onclick="hide()" />
            <input id="Button2" type="button" value="sethtml" onclick="sethtml()" />
            <div id="div1" style="display: none">
                <CE:Editor ID="Editor1" runat="server">
                </CE:Editor>
            </div>
        </form>
    </body>
    </html>
    -------------------------------------------------------------->
     
    Regards,
     
    Ken
  •  04-28-2009, 9:06 AM 51608 in reply to 51605

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

    Hi Kenneth,
     
    I have the latest build.  I just downloaded it for a third time a few minutes ago.
     
    Your sample code yielded the exact same results for me as my own code (whew - I'm not crazy).  I posted it to my site.  Go to http://bayareacareerpathways.org.previewdns.com/test.aspx to see it first-hand.
     
    After the page first loads, if you click the sethtml button, you get an error: Object doesn't support this property or method.
     
    If you first click show, then click sethtml, it works just fine: the word test shows up in the editor.
     
    If you first click show, then hide, then click sethtml, again it works fine.  There is now error, and if you click show again the word test is right in there.
     
    Also, I noticed that when you first click show (after loading the page), the editor that comes up is blank - it has no icons or dropdowns - it's just a blank text area.  After a split second it populates all the icons and dropdowns.
     
    So my guess is that if the editor is in a non-displaying div, then it doesn't instantiate itself until the div is shown. 
     
    Thanks!
     
    Aaron
  •  04-28-2009, 9:50 AM 51610 in reply to 51608

    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
  •  05-07-2009, 6:15 AM 51923 in reply to 51610

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

    Hi aaron,
     
    Try this example:
     
    --------------------------------------------------------------->
     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">


    <head id="Head1" runat="server">
        <title>DataList Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <input id="Button1" type="button" value="show" onclick="show()" />
            <input id="Button3" type="button" value="hide" onclick="hide()" />
                    <div id="div1" style="display: none">
                <CE:Editor ID="Editor1" runat="server">
                </CE:Editor>
            </div>
        </form>
    </body>
    </html>

    <script>
    function show()
    {
    var div1=document.getElementById("div1");
    div1.style.display="block";
    }
    function hide()
    {
    var div1=document.getElementById("div1");
    div1.style.display="none";

    }
    function CuteEditor_OnInitialized(editor)
    {
      editor.setHTML("test");
    }
    </script>
     
     
     
    --------------------------------------------------------------->
     
     
    Regards,
     
    Ken
View as RSS news feed in XML