title: How to know if there is a link element within the selection
body: <p>In Javascript, I'd like determine whether an element, say an <code>A</code> element, exists inside a given range/textRange.  The aim is to determine if the user's current selection contains a link.  I am building a rich text editor control.</p>
  
  <p>The range object has a commonAncestorContainer (W3C) or parentElement() (Microsoft) method which returns the closest common anscestor of all elements in the range.  However, looking inside this element for <code>A</code> elements won't work, since this common ancestor may also contain elements that aren't in the range, since the range can start or end part way through a parent.</p>
  
  <p>How would you achieve this?</p>