0

I'm trying to find a way in javascript to open all external links (or better: all links that normally open in a new window/tab) in a modal box instead.

Essentially I'm looking for a way to attach a listener to external links (that are not targeting the same window) and open them to my modal box instead of opening a new window.

Most ideally it shouldn't matter if a popup is generated by a _blank anchor or by javascript/any other way.

Trying to accomplish this in vanilla javascript.

Thank you so much for your help!

Henny Mugge
  • 35
  • 1
  • 6
  • Not sure how you are going to add them to a modal, guessing iframe? So bind a click handler to them and call your modal code... – epascarello Feb 05 '19 at 17:19

1 Answers1

0

Most of this seems to be like your question:

Opening an external website in a modal popup

The iframe element inside a modal can read the external site, and you could change the src attribute dinamically.

Edgar Valfogo
  • 47
  • 1
  • 7
  • Thanks! I know how to load external content in modal boxed. Maybe I didn't describe my question enough: i'm injecting javascript in a webview, which can't open popups. To mimic popup functionality, I want to open "popups" in a modal. – Henny Mugge Feb 05 '19 at 21:32
  • So I understand: You already have a box that opens an external site and you want to open a Modal inside it, through a command given by the "parent" of this iframe, right? – Edgar Valfogo Feb 06 '19 at 18:52
  • I have found a solution by adding an eventlistener('newwindow') to my webview. This way I can call a modalbox with the external webpage in my app whenever a newwindow is called. Thanks for your help! – Henny Mugge Feb 08 '19 at 15:51