Skip to content

Commit

Permalink
Warn when iframe unexpectantly removed from page
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjbradshaw committed Apr 5, 2015
1 parent 6e817dc commit aef5326
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@

function checkIFrameExists(){
if (null === messageData.iframe) {
throw new Error('iFrame ('+messageData.id+') does not exist on ' + page);
warn('iFrame ('+messageData.id+') does not exist on ' + page);
return false;
}
return true;
}
Expand Down Expand Up @@ -411,8 +412,13 @@
}

function trigger(calleeMsg,msg,iframe){
log('[' + calleeMsg + '] Sending msg to iframe ('+msg+')');
iframe.contentWindow.postMessage( msgId + msg, '*' );
if(iframe && iframe.contentWindow){
log('[' + calleeMsg + '] Sending msg to iframe ('+msg+')');
iframe.contentWindow.postMessage( msgId + msg, '*' );
} else {
warn('[' + calleeMsg + '] IFrame not found');
}

}


Expand Down

0 comments on commit aef5326

Please sign in to comment.