I am trying to close a window which have been opened in the following way:
var myWindow;
function openLink(){
myWindow = window.open("http://mydir.com", "MsgWindow", "width=600, height=400, left=250, top=200");
}
This opens a window inside a some kind of popup (Here you can see how it works)
What i want to do is when my ajax call finishes (in the opened window) close the window. I am trying with this:
$.ajax ({
url: "php/copia.php",
type: "post",
data: {"params": result,
"dirDest":dirDest},
success: function(response) {
$.mobile.loading('hide');
window.parent.postMessage('Close popup', '*');//I am trying to send a message to the parent window but it doesnt work
}
});
In the window which opens the new window i have the following:
$( document ).ready(window.addEventListener("message", closePopup, false));
function closePopup(event) {
myWindow.close();
}