Re: How to get html DOM of IMG element of selected image in Firefox

  •  11-15-2009, 11:57 PM

    Re: How to get html DOM of IMG element of selected image in Firefox

    function getSelectedHTML()   
    {      
          var rng=null,html="";         
          
          // get the active editor document
          var editdoc = editor1.GetDocument();

          // get the active editor window 
          var editwin = editor1.GetWindow();   
          if (document.selection && document.selection.createRange)   
          {      
                rng=editdoc.selection.createRange();   
               if( rng.htmlText )    
               {    
                  html=rng.htmlText;    
               }    
               else if(rng.length >= 1)    
               {    
                  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;   
     
     
    Using above function I am able to get  selected html:
    http://cutesoft.net/developer+guide/scr/Get-HTML-from-Selection.htm
     
    Now, I need to add NAME and ID attribute to IMG element. 
     
    In IE, highlighted line gives IMG element DOM, but in Firefox no luck, any ideas?
     
    Thanks,
    Maulik 
    Filed under: ,
View Complete Thread