title: jquery iframe a links into new div / tab / window?
body: <p>I have a tricky question.</p>
  
  <p>All pages are within same server / portal.</p>
  
  <p>I have a page that embeds iframe from the other page using the following code:</p>
  
  <pre><code>$('#mydiv').append('&lt;p id="loading"&gt;Loading ...&lt;/p&gt;');
  $('#mydiv').append('&lt;iframe id="myframe" name="myframe" class="myframe" onload="myframe()" style="display:none;"&gt;&lt;/iframe&gt;');
  $('#myframe').attr('src', 'https://mywebsite.com/page2');
  
  function myframe() {
  var $myframesearch =  $('#myframe').contents(); 
  $myframesearch.find("a").attr('target','_parent');
  }
  
  $('#myframe').load(function(){
  $('#loading').remove(); 
  $('#myframe').fadeIn();
  });
  </code></pre>
  
  <p>All of the links within iframe have no href (but href="javascript:void(0)") and uses scripts within iframe to process the action dynamically.</p>
  
  <p>Some links does open in new window some does not.</p>
  
  <p>I would like to force all links to either open in new Tab, Window, or append to new Div, but none of the methods work, like base / parent, onclick / new window, _top, _parent, etc.</p>
  
  <p>However, my idea was to hide and wait till the content of iframe is loaded after a click and then to append loaded content in new hidden div and then fade it in. When doing so the loaded iframe content resets back to default and not with new content.</p>
  
  <p>Does anyone knows how this can be solved? </p>
  
  <p>Thank you all!</p>