title: Add target=_blank to every link in a HTML string
body: <p>I have a string <code>s</code> (paragraph of text in HTML format) and I'm using this to include it in a <code>div</code>.</p>
  
  <pre><code>document.getElementById("mydiv").innerHTML = s;
  </code></pre>
  
  <p><code>s</code> might contain a few <code>&lt;a href="..."&gt;...&lt;/a&gt;</code> links. <strong>How to automatically add <code>target="_blank"</code> to these links?</strong> (so that if the user clicks on them, it won't replace the current page)</p>
  
  <p>I was thinking about using some kind of regex to detect links in <code>s</code>, detect if target=_blank is already present, and if not, add it, but this seems complicated.
  Would it be better to add <code>target=_blank</code> after <code>s</code> is inserted in the DOM after <code>.innerHTML = s</code>? If so, how?</p>