Interplex

by TokenEx Support

HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<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/Interplx/Iframe/642c3b7fe4014b04b07842623a122492" ></iframe> </br>

<button type="button" id="bthSubmit">Post Iframe</button>

CSS

</style>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">
<style>

JavaScript

document.getElementById('bthSubmit').onclick = submit;

//add event listener for postmessage
if (window.addEventListener) {
  addEventListener("message", listener, false)
} else {
  attachEvent("onmessage", listener)
}

//submit the iframe post
function submit() {
  var iframe = document.getElementById("iframe");
  iframe.contentWindow.postMessage('', "https://test-htp.tokenex.com");
}

//handle the message from the iframe
function listener(event) {
  if (event.origin === 'https://test-htp.tokenex.com') {
    log("<em>Received from the iFrame:" + event.data + "</em>")
    //do something with the JSON.
    var response = JSON.parse(event.data);

  } else {
    log("<em>Origin: " + event.origin + " isQn't allowed</em>")
  }
}

function log(message) {
  document.getElementById("data").innerHTML += message + "<br /><br />";
}