Modal Dialog box get HTML issue

Last post 02-22-2008, 4:06 PM by Efinity. 1 replies.
Sort Posts: Previous Next
  •  02-22-2008, 4:04 PM 37300

    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;

    }

     
  •  02-22-2008, 4:06 PM 37301 in reply to 37300

    Re: Modal Dialog box get HTML issue

    I should specify that a text selection includes the anchor tag, while an image selection doesn't.  So my issue is only when an image is selected in the editor retrieving the anchor for it.
View as RSS news feed in XML