title: javascript to open all html links in a new tab?
body: <p>I need to be able to set, in javascript, all html page links to open in a new tab, how can I do that?</p>
  
  <p>Can it be attributed to the div "links"?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Negócios&lt;/title&gt;
  
  
  &lt;script type="text/javascript"&gt;
  &lt;/script&gt;
  
  
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
  &lt;div id="links"&gt;
  &lt;p&gt;&lt;a href="https://www.facebook.com/groups/ivendi.maringa2/" data-hovercard="/ajax/hovercard/group.php?id=472352436193468" aria-owns="js_1j" aria-haspopup="true" id="js_1k"&gt;MARINGÁ - NEGÓCIOS&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;&lt;a href="https://www.facebook.com/groups/638497612850047/" data-hovercard="/ajax/hovercard/group.php?id=638497612850047" aria-owns="js_1l" aria-haspopup="true" id="js_1m"&gt;MONTES CLAROS - NEGÓCIOS&lt;/a&gt;&lt;br&gt;
  &lt;/p&gt;
  &lt;p&gt;&lt;a href="https://www.facebook.com/groups/aggape/" data-hovercard="/ajax/hovercard/group.php?id=538358279511007" aria-owns="js_1r" aria-haspopup="true" id="js_1s"&gt;Sucesso Empresarial&lt;/a&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I need to do that without using the target attribute in the HTML. I have too many links, also, I want to learn how to do that.</p>