[thelist] Creating a link around an image using DOM

Anthony Baratta Anthony at Baratta.com
Fri Jun 27 15:43:43 CDT 2003


I'm working with IE 6.0 only. Anyone here successfully created 
links/anchors around images using DOM?

I'm trying to enhance the functionality of a basic JS-like WYSIWYG editor. 
I'm having problems creating an anchor tag around a selected image. I have the

   selectedRange = top.opener.document.selection.createRange();
   selectedHTML = selectedRange.htmlText;

returning the selected HTML, but when I try to use


It does not create the link around the selected image, it creates a new div 
wrapper. If I have "text selected" versus images, the above command works fine.

Any clues or pointers to good DOM How To's are appreciated.
Anthony Baratta
Keyboard Jockeys

"Conformity is the refuge of the unimaginative."

More information about the thelist mailing list