0
votes

I am using iframe to let user interactive with another web application. However, in the content of iframe, there are link that open new tab.

I want that these link open in the iframe rather than new tab.

However, editing the 3rd party web app is not an option. I need to control it from my Angular instead.

In simple, the solution maybe change all target="_blank" to target="_self". However, I don't know how to. Please give me code if this is the solution.

How can I prevent the iframe in Angular to open link in new tab and open in same iframe instead ?

1

1 Answers

0
votes

Could do something like this maybe:

let elements = document.getElementsByTagName('a');
for (let i = 0; i < elements.length; i++) {
    elements[i].target = '_self';
}

Will change all <a href.../> tags to be target _self