Gordon Gordon - 11 months ago 39
jQuery Question

"Open Link in new Tab" should not open the iFrame-source-page

So let's say I have page www.aaa.com/iframe-of-page-b. Inside of it I display page www.bbb.com as an iFrame.

My issue: When I now click "open link in new Tab" on a link inside that iFrame usually www.bbb.com opens as a new tab in my browser.

What I would like to accomplish: When clicking "open link in new Tab" inside that iFrame, I would like to open a page, that looks just like the one the user sees the iFrame first, so in this case it should open www.aaa.com/iframe-of-page-b with that www.bbb.com-iFrame inside of it and the link, that was clicked.

Answer Source

Solution 1

Generate links that re-create the IFrame'd page.

<a id="link1" href="/my_iframe_page.html?my_frame=some_frame">Link</a>

Then intercept the click event via JavaScript so that "normal" clicks change just the inner frame. Otherwise every time the user clicks it, the whole page (including the outer frame) will blink.

Solution 2

Prevent the links from opening in a new tab altogether

<a id="link1">Link</a>

Specify no href at all. "Open in new tab" browser menu won't work. To make normal clicks work, intercept the click event via JavaScript.