JSFiddle - React, Tailwind, and code Playground

by tnhu

HTML

<iframe id="iframe1" src="http://localhost:8090/applications"><body></body></iframe>

CSS

html, body, iframe {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}

iframe {
  margin-left: 320px;
  width: calc(100% - 320px);
}

JavaScript

// var script = "alert('hello world from within iframe');";
// $('#iframe1').contents().find('body').append($('<script>').html(script))

var iframe = document.getElementById('iframe1'),
    iframeWin = iframe.contentWindow || iframe,
    iframeDoc = iframe.contentDocument || iframeWin.document;

window.hello = function () {
    alert('hello from owner!');
};

$(iframeDoc).ready(function (event) {
    var iFrameHead = iframeDoc.getElementsByTagName("head")[0];         
        var myscript = document.createElement('script');
        myscript.type = 'text/javascript';
        myscript.textContent = 'alert("Script injected into ArgoCD"); console.log("login__text", document)';
        iFrameHead.appendChild(myscript);
});