Reputation: 7796
in both the cases , i am trying to close a popup window opened from the same parent using the similar code. In both cases the function is being called inside the call back function of the jquery $.post method. But while one of them works properly, the other one throws an error
Firefox:
window.close is not a function
Chrome:
Property 'close' of object [object DOMWindow] is not a function
I tried to do this separately with two simple html files having minimal code .. and it works perfectly
this is the code i am using to open the popups
<a onclick="window.open('<?php echo $personalize_href; ?>',null,'height=688,width=1000,status=no,toolbar=no,menubar=no,scrollbars=2,location=no');">
Please help
Upvotes: 0
Views: 761
Reputation: 7796
thanks Pekka..
this is how i am calling window.open
<a onclick="window.open('<?php echo $personalize_href; ?>',null,'height=688,width=1000,status=no,toolbar=no,menubar=no,scrollbars=2,location=no');" class="button">
by two different cases what i meant was, there is a parent window with two links which open two different popups .. one gets closed using window.close, the other doesnt and i am calling the window.close function from the popup windows in both the cases.. along with some other code which is this
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.href = 'xyz';
}
Upvotes: 0
Reputation: 163308
You can try self
instead of window
.
self
references the current window, whereas window
references the parent window.
self
is actually a DOMWindow
object.
Upvotes: 1
Reputation: 251242
You need to keep a handle to the window (or reclaim a handle to the window...)
var myWin = window.open(uri, "myWin", "height=300, width=200");
...
myWin.close();
Upvotes: 1