Reputation: 11
I am opening aspx.cs page from one html page. I want to close parent window from child window.I used window.opener.close().It is working properly in IE. But not working in mozilla browser.This is the code HTML page;
window.open("Default.aspx", null, "resizable=no,scrollbars=false,channelmode=yes,titlebar=yes,status=yes,toolbar=no,menubar=no,location=no");
Default.aspx page
if (window.opener != null) {
window.opener.open('', '_self', '');
window.opener.close();
}
Upvotes: 1
Views: 10192
Reputation: 1
You don't create a object:
var myWindow;
function myFunction() {
myWindow = window.open("organization.php", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=200,left=500,width=600,height=300");
}
function closeFunction(){
myWindow.close();
}
Upvotes: 0
Reputation: 324620
For security reasons, JavaScript can only close windows that were opened originally in JavaScript.
Your window.opener.open('','_self','');
line seems to be some kind of hack to trick the browser into thinking the window was opened by JS, so while it may work in some browsers there's no reason for it to work in all of them.
Upvotes: 1
Reputation: 148524
you must give him a name and not null
.
window.open("Default.aspx", "aaaa", "resizable=no,scrollbars=false,channelmode=yes,titlebar=yes,status=yes,toolbar=no,menubar=no,location=no");
Upvotes: 0