Re: firefox editor1.getselection is not a function

  •  09-27-2007, 8:45 AM

    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
View Complete Thread