</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/c411f0b177a64113860622655b5ffa6e" ></iframe> </br>
<button type="button" id="bthSubmit">Post Iframe</button>
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) {
//validate the origin is from TokenEx
if (event.origin === 'https://test-htp.tokenex.com') {
log("<em>Received from the iFrame:" + event.data + "</em>")
//do something with the JSON. i.e. add the token value to your page
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 />";
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.