There is function window.close() in javascript to close browser window. If we call it from the main browser window (not the one opened with window.open()) - we get:
"The page is trying to close the window" warning message.
This warning message shows up every time one tries to close browser window with window.close() function. It seems impossible to close the most outer main browser window and not to get this message.
But wait... window.close() function implementation is just so simple. It checks window.opener. If "opener" equals empty string it suspects that we talk about parent window (not the one that was opened with window.open(...)) and pop-ups warning. And it is easy to work around:
< a href="javascript:window.opener='x';window.close();">Close< /a>
#re: Javascript: How to close browser window (window.close()) without warning
Hi there, I tried to use the code above, and it does not work it keeps warning me that the page is being closed.. I'm using IE7 on Windows XP.. is there something else I need to do?, thanks..
#re: Javascript: How to Close Browser Window (window.close()) Without Warning
if you want to close window using a gif button
<A
onclick=top.close() href="javascript:void(0)"><IMG height=11 src="close.gif"
width=11 border=0></A>
or else use
<A
onclick=top.close() href="javascript:void(0)">Exit!!</A>
or else if you want to close window onload
for php users:
echo "<body onload=top.close() href=\"javascript:void(0)\ content='10\">";
for html:
<body onload=top.close() href="javascript:void(0) content='10">
#re: Javascript: How to Close Browser Window (window.close()) Without Warning
I have the same problem, I've tried different scripts, But nothing works... When I try it in IE7, It keeps on asking if I want to close the window... Can anyone help me?
this is where my file is: www.thatsteve.be/menu/start.htm
The thing is, I want to open a website in a window without menu or adresbar, or anything... just a window...
So I've made a normal page that calls a javascript to open a popup... In this popup my website shows.... So far so good.... Now, when the popup has loaded, I want the first window to close.... And that's when I get the message... Please help me...
#re: Javascript: How to Close Browser Window (window.close()) Without Warning
Hello.. First of all... my english isn't very well. I'm sorry for this..
my problem is like this....
I have a website that designed by visual studio 2005 c#
I open a parent window. the window has a child window.
I'd like close the parent window when the child window open.
I close the parent window with javascript.. that works good in Internet
Explorer but it doesn't work in mozilla firefox. the window cannot close
#re: Javascript: How to Close Browser Window (window.close()) Without Warning
Hi
Here is the code to make close the parent window without warning, in both IE and Firefox. Paste it in an HTML and enjoy
<html>
<head>
<script language="javascript" type="text/javascript">
function closeWindow() {
//uncomment to open a new window and close this parent window without warning
//var newwin=window.open("popUp.htm",'popup','');
if(navigator.appName=="Microsoft Internet Explorer") {
this.focus();self.opener = this;self.close(); }
else { window.open('','_parent',''); window.close(); }
}
</script>
</head>
<body>
<a href="javascript:closeWindow();">Close Window</a>
</body>
</html>