Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Getting parent notifications from DCE player iframe.">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <iframe src="https://matterhorn.dce.harvard.edu/engage/player/watch.html?id=74b6c02f-afbb-42bc-8145-344153a1792e">
    
  </iframe>
  
  <ul id="events">
  </ul>
</body>
</html>
 
  var eventList = document.querySelector('#events');
  var iframe = document.querySelector('iframe');
  window.addEventListener('message', receiveMessage, false);
function receiveMessage(event) {
  var eventItem = document.createElement('li');
  eventItem.textContent = JSON.stringify(event.data, null, '  ');
  eventList.appendChild(eventItem);
  if (event.data.name === 'ready') {
    var playMessage = {
      sender: 'gov2001',
      name: 'play'
    };
    iframe.contentWindow.postMessage(playMessage, '*');
  }
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers