简体   繁体   中英

Is it possible to open a pop up in an iframe

Is it possible to force a pop up to open in an iframe where the action to open the pop up has taken place?

I have a VueJs Application that displays a website inside an iframe and don't want the application to open new windows. But it is also not acceptable to just block all the popups with sand boxing, as some contain critical functionality.

Thus i am looking for any way to "force" target="_blank" onto the link on the webpage. I know that there is no standard way to do so, but would be open for any suggestion on how to alternatively solve this.

Maybe there is a way to disable the browsers ability to open new windows and hijack the calls.

Looking forward to your answers.

That capability is all or nothing, mostly. Since it's a different site in the iframe , you likely don't have access to the iframe content and so can't control the links in it.

iframe has a sandbox attribute to which you could add the allow-popups option

  • allow-popups : Allows popups (such as window.open() , target="_blank" , or showModalDialog() ). If this keyword is not used, the popup will silently fail to open.

As in:

<iframe ... sandbox="allow-popups"></iframe>

There's also:

  • allow-popups-to-escape-sandbox : Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.
  • allow-modals : Lets the resource open modal windows .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM