javascript - How to check whether child window exists if parent window redirects to some other page -


on clicking button child window opened:

<button id="btn" onclick="mywindow = window.open('http://www.example.com/index', '', 'toolbars=0,resizable,scrollbars')">start</button> 

the parent window redirect page on button click.

$('#btn').click(function(){     parent.location.href = 'http://www.example.com/popup'; }); 

if did not redirect parent window, able check whether child window exist parent window this:

if(!mywindow.closed){     alert('yup, still there.');} 

since parent window redirecting not able check whether mywindow closed or not.

how possible?

its not possible javascript on easy way. because of security. imagine mess whould if website access tabs have opened. javascript limited dom of page it's delivered with.

so can using websockets. there rails implementation of websockets called websocket-rails. allows communicate clients asynchron. whould enable implement method verifies vertan page opened client.

websockets arent easy understand in beginning definitfily worth read!


Comments