How to detect in post.message null var?
How to detect in post.message null var?
Hello I need detect if child.php not send message to parent.php, I use the post.message .
I try with:
if (message == null), == false, == "", but not work ..
My code:
parent.php (get the message "work" from child.php if its open)
<button id="open-child-window-2">Open Child Window</button>
<script>
var __CHILD_WINDOW_HANDLE_2 = null;
$("#open-child-window-2").on('click', function() {
__CHILD_WINDOW_HANDLE_2 = window.open('child-2.php', '_blank');
});
window.addEventListener('message', function(e) {
ProcessChildMessage_2(e.data);
} , false);
function ProcessChildMessage_2(message) {
alert(message);
}
</script>
child.php (send to parent.php the message "work" every 0.5 seconds)
<script>
setInterval(function(){
window.opener.postMessage("work", "*");
},500);
</script>
I need detect if chiel.php not send "work" to parent.php, for example:
Thanks you so much
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.