JSFiddle - React, Tailwind, and code Playground
HTML
<div id="openIFrame" data-file="test.html">link</div>
JavaScript
// First, get a reference to the HTML element you wish to work with.
// There are many ways to do this (via an id, via a CSS selector, via
// the element's position in the document) with .getElementById() or
// .querySelector(), etc. Here, I've used an id in the HTML, so we'll
// get the element by its id:
var link = document.getElementById("openIFrame");
// Next, register the event handling function with the event
link.addEventListener("click", myFunctionA);
function myFunctionA() {
// When the function is invoked, the keyword "this" will be bound to the HTML
// element that triggered the event. From there, you can access your custom
// data property with: dataset.propName which only needs to be passed to your
// window.open invocation since the only thing you want in the new window is
// the contents of the new file:
var myWindow = window.open(this.dataset.file, "MsgWindow", "width=1000,height=700");
}