|
Q945 Is there any way to close the browser window without the confirmation dialog that pops up when using "window.close()"?
irt.org | Knowledge Base | JavaScript | Window | Q945 [ previous next ]
Q945 Is there any way to close the browser window without the confirmation dialog that pops up when using "window.close()"?
In the parent document:
<script language="JavaScript"><!--
var popup = window.open('child.html','windowName','width=640,height=480');
if (!popup.opener) popup.opener = self;
//--></script>
|
and in the child document:
<script language="JavaScript"><!--
if (opener.history.length > 1) {
opener.history.go(1-opener.history.length);
setTimeout('opener.close()',1000);
}
else
opener.close();
//--></script>
|
The following was submitted by Jam AJT Systems
Try:
window.opener=self
window.close()
|
The following was submitted by Jason Schulte
The only reason you can't do this is because you can only close windows that you are the owner of without confirmation:
<script language=javascript>
true_content = window.open('true_content.html','','');
window.name="my_window";
</script>
|
Then in true_content.html:
<script>
main_window = window.open('http://'+location.host+'/blank.php','my_window','');
main_window.blur();
main_window.opener=self;
setTimeout('main_window.close()',500);
</script>
|
The following was submitted by Eric "Clad" Sakariasen
I have found this works in IE 5.5 only. I know its not much but its a start.
In the parent window:
<script>
window.open('popup.html','_blank','height=1,width=1');
</script>
|
In the child window:
<script>
opener.top.opener=top;void(0);
opener.top.close();
self.close();
</script>
|
The following was submitted by joe c - it only works with IE5+:
<html>
<head>
<title>Exit</title>
<script language = "Javascript">
var win;
function openWin() {
eval("win=window.open('fullscreen.htm','winone','width="+screen.width+",height="+(screen.height-20
+",toolbar=no,menubar=no,status=yes,scrollbars=no,resizable=no,top=0,left=0,fullscreen=no')");
win.moveTo(0,0);
}
var ie5IsUp = false;
function closeMe() {
var browserType = navigator.appName;
var browserVersion = parseInt(navigator.appVersion);
if (browserType == "Microsoft Internet Explorer") {
if (ie5IsUp) {
closecontrol.Click();
}
}
}
</script>
</head>
<!--[if IE 5]>
<SCRIPT LANGUAGE="Javascript">
ie5IsUp = true;
</SCRIPT>
<![endif]-->
<body bgcolor="#003366" text="#FFFFFF" onload="openWin()" onfocus="JavaScript:closeMe()">
<object id="closecontrol" type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"
codebase="hhctrl.ocx#version=4,72,8252,0" width="100" height="100">
<param name="command" value="close">
</object>
</body>
</html>
|
Feedback on 'Q945 Is there any way to close the browser window without the confirmation dialog that pops up when using "window.close()"?'
|
|