Open iframe source in new tab
<p>I've got an iframe that people can navigate through to get to a specific place, but as it is cross-domain some of the javascript on the site doesn't work (Such as looking at product history for example...)</p>

<p>I've been trying to find a way to make a button that will take whatever page the user is on in the iframe and open that link in a new tab.</p>

<p>While trying to research if this was possible, all I could find is people opening links from within an iframe in a new tab, which is <strong>not</strong> what I need.</p>

<p>I need to make a button that onclick will open a new tab with whatever link the user is currently on in the iframe.</p>

<p>I haven't really tried many things because I cannot find anything on the subject (Probably due to terrible wording), but I'm thinking my best chance is jquery/javascript, however, I'm not very fluent in javascript.</p>

<p>So my question is, is it possible to open an iframes url into a new tab, and if so, what would be the most efficient way to do so?</p>

<p><em>The website that is in my iframe is cross-domain and I cannot edit its source.</em></p>

<p>What I currently have is this:</p>

<pre><code>&lt;iframe id="iframe" class="frame" name="iframe" height="100%" width="100%" onload="refreshLink(this.contentWindow.location.href)"&gt;&lt;/iframe&gt;
</code></pre>

<p>Note: The src is set by javascript on page load.</p>

<p>Under that I have:</p>

<pre><code>                                &lt;script&gt;
                                var hyperLink = document.getElementById("iframe").src;

                                function refreshLink(link) {
                                    hyperLink = link;
                                    document.getElementById("button").href=hyperLink;
                                }
                                &lt;/script&gt;
</code></pre>

<p>Above all of that I have:</p>

<pre><code>&lt;a href="#" target="_blank" class="btn btn-info" id="button"&gt;Open in R1&lt;/a&gt;
</code></pre>

<p>But, when I click the button at any given time it opens a new tab to the same url I was at before (a tab that goes to the same page the iframe is displayed on).</p>