Modal Dialog box get HTML issue

  •  02-22-2008, 4:04 PM

    Modal Dialog box get HTML issue

    I have a dialog box that I'm opening from a custom button.  I want to extract the anchor tag from the selection in the editor.  I have this working in IE without a problem.  From the code below I'm able to alert and get access to the <a> in IE.  I've tried parentNode for Firefox, but I keep getting "parentNode has no properties".  Any help would be appreciated
     

    //Collect HTML from window

    function getSelectedHTML(){

    var editor1 = Window_GetDialogArguments(window)
     
    var editor1doc = editor1.GetDocument();

    var editdoc=editor1.GetDocument();

    var editwin = editor1.GetWindow();

    var rng=null,html="";

    var myFunction

    if (document.selection && document.selection.createRange){

    rng=editdoc.selection.createRange();

    html=rng.htmlText;

    alert("parent:"+rng.parentElement().tagName); //alerts parent element IE only...gets the anchor tag

    if(html == undefined){html = rng.item(0).outerHTML;} // will detect the HTML for images/objects IE

    }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