How to get "SRC" or URL or tag of selected image

  •  07-14-2006, 8:10 AM

    How to get "SRC" or URL or tag of selected image

    Hi,
     
    I have used the following code to get the src of a selected image:
     
    if(editselection.type=='Control')
     {
         if(range.length==1)
        {
            var element=range.item(0);
      
            if(element.tagName=='IMG')
           {
               // alert(element.src);
              textBox.value=element.src;
           }
        }
     }
     
    I would like to get the whole tag as I will be using it to create a URL
     
    This is the whole tag
    <img src="../filemanager/previewfile.ashx?id=57917&amp;thumb=true">
     
    This is returned by element.src;
     
    So, I have 2 problems:
     
    How do I get the whole tag out?
     
    How do I stop it from returning
    instead of
    ../filemanager/previewfile.ashx?id=57917&amp;thumb=true
     
    Thank you.
     
     
View Complete Thread