Reputation:
//Parent page javascript
function DoABC()
{
//my logic goes here
}
function btnClick() //This function gets fired on the click event of a button which will open a child window now
{
window.open("childpage.html", "_blank", "height=400, width=550, status=yes, toolbar=no, menubar=no, location=no, addressbar=no");
}
Now when I close this child form, after it gets closed, I want to call DoABC function.
I tried using window.onbeforeunload event of child window, but it did not work for me.
window.onbeforeunload = function(event) {
event = event || window.event;
var confirmClose = 'Are you sure?';
// For IE and Firefox prior to version 4
if (event) {
event.returnValue = "Are you sure";
}
// For Safari
return confirmClose;
}
What could be the solution for this?
Upvotes: 0
Views: 1389
Reputation: 1675
When you call window.onbeforeunload, you are referring to your current window object. I would think this would work:
var newWin = window.open(....);
newWin.onbeforeonload = function () {....}
I haven't tried, but I think this will solve your problem.
Upvotes: 1