title: target iframe when iframe name is dynamic
body: <p>My problem is targeting an iframe with a dynamic name added from jquery. It seems when I attempt to add name to iframe dynamically, links targeting the iframe, open in a new window. </p>
  
  <p>The test code is simple:</p>
  
  <p>html:</p>
  
  <pre><code>&lt;a href="https://www.gaugeonline.com/" target="iframe1"&gt;test&lt;/a&gt;
  &lt;iframe src="https://test.com"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>jquery:</p>
  
  <pre><code>$('iframe').attr('name', 'iframe1');
  </code></pre>
  
  <p>I made a simple fiddle: <a href="https://jsfiddle.net/2ztg7xpj/1/" rel="nofollow noreferrer">https://jsfiddle.net/2ztg7xpj/1/</a></p>
  
  <p>I also tried adding both the target and name dynamically:</p>
  
  <p>html:</p>
  
  <pre><code>&lt;a href="https://www.gaugeonline.com/"&gt;test&lt;/a&gt;
  &lt;iframe src="https://test.com"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>jquery:</p>
  
  <pre><code>$('iframe').attr('name', 'iframe1');
  $('a').attr('target', 'iframe1');
  </code></pre>
  
  <p>and the fiddle: <a href="https://jsfiddle.net/2ztg7xpj/2/" rel="nofollow noreferrer">https://jsfiddle.net/2ztg7xpj/2/</a></p>
  
  <p>So the question is, why is this the behavior for a dynamically added iframe name and is there some sort of work around (other than adding name directly to the iframe)</p>