Re: problem with GetSelection() in IE for custom button with popup

  •  11-14-2008, 2:36 AM

    Re: problem with GetSelection() in IE for custom button with popup

    This solution seems to work :
     
    function getSelectedHTML() {
        var editor1 = Window_GetDialogArguments(window)
        var editdoc = editor1.GetDocument();
        var editwin = editor1.GetWindow();
        var rng=null, html="";
        if (document.selection && document.selection.createRange) {
            rng=editdoc.selection.createRange();
            html=rng.htmlText;
            if(html == undefined) {
                html = rng.item(0).outerHTML;
            }
        }
        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;
    }
View Complete Thread