JSFiddle - React, Tailwind, and code Playground
HTML
<h1>Test Page</h1>
</br>
<p id="data"></p>
<!--update the src of this iframe to the HTPURL you obtained from the https://test-htp.tokenex.com/api/session call -->
<iframe id="iframe" width="30%" height="20%" scrolling="no" frameborder="0" src="https://test-htp.tokenex.com/Demo/IFrame/df215b1c9fcd4d28b537fa20bb0ed35d" ></iframe> </br>
<button type="button" id="bthSubmit" onclick="submit()">Post Iframe</button>
JavaScript
if (window.addEventListener){
addEventListener("message", listener, false)
} else {
attachEvent("onmessage", listener)
}
function submit(){
var iframe = document.getElementById("iframe");
iframe.contentWindow.postMessage('',"https://test-htp.tokenex.com");
}
function listener(event){
if (event.origin == 'https://test-htp.tokenex.com') {
log("<em>Received from the iFrame:" + event.data + "</em>")
}
else{
log("<em>Origin: " + event.origin + " isn't allowed</em>")
}
}
function log(message){
document.getElementById("data").innerHTML += message + "<br /><br />";
}