Problem with JS API

Last post 11-15-2008, 1:45 AM by mireigi. 2 replies.
Sort Posts: Previous Next
  •  11-14-2008, 3:29 AM 45723

    Problem with JS API

    Hi,
     
    I'm having some problems with the JavaScript API in a C# ASP.NET project when viewed in FireFox 3.0.3
     
    I am loading the editor (CE) when the page is generated. When the user clicks on a button (input type - no postback), the editor is brought up at the location of the button, and the text is set to the value of a hidden field before finally setting Focus to the editor.
     
    My problem is that the focus doesn't work.
     
    The script I am using is based on AJAX:
    function showEditor(target)
    {
       var elementRef = $get(target);
       var elementLoc = Sys.UI.DomElement.getLocation(elementRef);
     
       var editorBox = document.getElementById("editorBox");
       editorBox.style.position = "absolute";
       editorBox.style.visibility = "visible";
       Sys.UI.DomElement.setLocation(editorBox, elementLoc.x, elementLoc.y);
                                                                
       var editor = document.getElementById("CE_Editor_ID")
       var editDoc = editor.GetDocument();
                                                                
       editor.FocusDocument();
       editor.SetHTML(document.getElementById("temp").value);
    }

    target = ID of the target pressed
    editorBox = The Table in which the editor is placed
    editor = The editor that I want to use
    temp = The hidden field containing the initial text, if any, for the editor.
     
    If anyone could tell me what I am doing wrong, then place let me know, as this is my 2nd day dealing with a workaround for this problem.
     
    Thanks in advance,
    Mireigi
     
    Edit: Found out that there is only a problem when viewing in Firefox.
  •  11-14-2008, 9:33 AM 45765 in reply to 45723

    Re: Problem with JS API

    Change:
     

       var editor = document.getElementById("CE_Editor_ID")
       var editDoc = editor.GetDocument();
       editor.FocusDocument();
       editor.SetHTML(document.getElementById("temp").value);

     
    to:
     
       var editor = document.getElementById("<%=Editor1.ClientID%>")
       
    alert(editor .getHTML());

       var editDoc = editor.GetDocument();                                                            
       editor.FocusDocument();
       editor.SetHTML(document.getElementById("temp").value);
     
    Then try again.
     

    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

  •  11-15-2008, 1:45 AM 45793 in reply to 45765

    Re: Problem with JS API

    I will try that when I get back to work monday.
     
    However, I fail to see the difference between:

    var editor = document.getElementById("CE_Editor_ID")
    and
    var editor = document.getElementById("<%=Editor1.ClientID%>")
     
    since the latter returns the same ID used in the former.
View as RSS news feed in XML