var iframe = document.getElementById('myIFrame');
iframe.contentWindow.body.addEventListener('mouseup', Handler);
function Handler() {
alert('works');
}
var iframe = document.getElementsByTagName('iframe')[0],
iDoc = iframe.contentWindow // sometimes glamorous naming of variable
|| iframe.contentDocument; // makes your code working :)
if (iDoc.document) {
iDoc = iDoc.document;
iDoc.body.addEventListener('afterLayout', function(){
console.log('works');
});
};