firefox editor1.getselection is not a function

Last post 09-27-2007, 10:47 AM by pascalli. 4 replies.
Sort Posts: Previous Next
  •  09-24-2007, 12:32 PM 33786

    firefox editor1.getselection is not a function

    I have a pop up box which loads a file, and merges in the location (url) into the html content of the editor. Works wonderfully in IE, but firefox generates the following error:
     
    editor1.GetSelection is not a function
     
    The pop-up window calls a function on the opening page:
    <script>
    var selText = parent.opener.getSelText();
    </script>
     
    and the function on the opening page is:
     
    function getSelText()
     {
      var editor1 = document.getElementById('CE_Editor1_ID');
     
    var sel=editor1.GetSelection();
       
       
     return sel.text
    }
     
    I am thinking it's a DOM issue or something, but its been years since i've wrestled with this type of thing. Any help would be greatly appreciated.
     
    Thanks
  •  09-24-2007, 1:34 PM 33789 in reply to 33786

    Re: firefox editor1.getselection is not a function

    pascalli,
     
    Your code is wrong. Please use the code below:
     

      function getSelectedHTML(){
          var rng=null,html="";

          if (document.selection && document.selection.createRange){
            rng=editdoc.selection.createRange();
            html=rng.htmlText||"";
          }else if (window.getSelection){
            rng=editwin.getSelection();

            if (rng.rangeCount > 0 && window.XMLSerializer){
              rng=rng.getRangeAt(0);
              html=new XMLSerializer().serializeToString(rng.cloneContents());
            }
          }
          return html;
        }

     
     

    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

  •  09-27-2007, 8:45 AM 33866 in reply to 33789

    Re: firefox editor1.getselection is not a function

    Sorry, inherited code. Did a bit more digging.
    Version 5.1
     
    What is supposed to happen - Select text and click a custom button. A pop up box displays the text (hence the getselection call), and have the user file in a form to generate a link, which is then returned to the calling editor.
     
    For example "click_here" becomes "<a href="http://www.yoursite.com">click_here</a>"
     
    in firefox the error is "editor1.getwindow is not a function
     
    in IE its an object or methd not found.
     
    I had to add some declarations to the code you supplied (for editor1,editwin,editdoc) so the function looks like:
     
    function getSelectedHTML(){
          var rng=null,html="";
    var editor1 = document.getElementById('CE_Editor1_ID');
          if (document.selection && document.selection.createRange){
     var editdoc = editor1.GetDocument();
            rng=editdoc.selection.createRange();
            html=rng.htmlText||"";
          }else if (window.getSelection){
    var editwin = editor1.GetWindow();
            rng=editwin.getSelection();

            if (rng.rangeCount > 0 && window.XMLSerializer){
              rng=rng.getRangeAt(0);
              html=new XMLSerializer().serializeToString(rng.cloneContents());
            }
          }
          return html;
        }

    Am I missing something really obvious?
     
    Do you have a 5.1 reference available I can dig through somewhere?
     
    Thanks
  •  09-27-2007, 9:40 AM 33870 in reply to 33866

    Re: firefox editor1.getselection is not a function

    pascalli,
     
    For version 5.x, please change
     
    var editor1 = document.getElementById('CE_Editor1_ID');
     
    to:
    // get the cute editor instance
    var editor1 = obj_Editor1;

    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

  •  09-27-2007, 10:47 AM 33875 in reply to 33870

    Re: firefox editor1.getselection is not a function

    Got it working.
    Thank you very much.
View as RSS news feed in XML