When our browser-based eID workflows are run in an HTML iframe, it is good to set up an event listener on the parent window, to get a JS-event notification when the login workflow is completed either with a success or an error.

See MDN Mozilla Developer Network – Window.postMessage()

The event.data contains an object as below, where command will always be set to ‘zignsec_postback’.

Setup Eventlistener

HTML and Javascript example:

Javascript Event Response: NOEVENT

<script type="text/javascript"> window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { var response = event.data; document.getElementById('event_response').innerText = "Javascript Event Response: " + response; } </script>

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Event Data Returned on Cancelled Login

Json example:

{
   "command":"zignsec_postback",
   "errorcode":"USER_CANCEL",
   "error":"Action cancelled",
   "token":"a54330cd-90dc-41f8-bcd5-22d87701d876"
}

Event Data Returned on Successful Login

Json example:

{
   "command":"zignsec_postback",
   "errorcode":"",
   "error":"",
   "token":"1decb781-37db-4477-92f8-223586dd4f0f"
}