Click here to Skip to main content
15,438,202 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to close the window containing lots of opened tabs in IE 8.0 and mozilla in asp.net.
i have used all this java script code,but it only close current tab ,i want to close browser window.
Posted
Updated 17-Apr-11 19:38pm
v3
Comments
Albin Abel 16-Apr-11 8:07am    
Windows opened by you? Yes close it. You got many answers I hope. Windows opened by the user, please don't think about closing it.
Dalek Dave 16-Apr-11 9:28am    
Edited for Grammar.

First instead of adding answer just add comment
Second try google for this
And third this may help you
XML
Response.Write("<script language='javascript'>parentwin = window.self;
parentwin.opener = window.self;
parentwin.close(); </script>");
 
Share this answer
 
Comments
Dalek Dave 16-Apr-11 9:29am    
Seems reasonable.
[no name] 18-Apr-11 4:23am    
Thanks Dalek
then You Go Like This
script is
var arrWindowRefs = [];
//... assume many references are added to this array - as each window is open...
//Close them all by calling this function.
function CloseSpawnedWindows() {
   for (var idx in arrWindowRefs)
      arrWindowRefs[idx].close();
}
 
Share this answer
 
v2
Comments
Dalek Dave 16-Apr-11 9:30am    
Edited for Code Block.
hi.
you can use of this sample in IE:

XML
<script language="javascript">
function closewindow()
{
window.close();
;
}
 </script>
 
Share this answer
 
v2
Use window.close in javascript that's it
 
Share this answer
 
Comments
Dalek Dave 16-Apr-11 9:28am    
I think he means programmatically! :)
Here a bunch for you.....

How can I close a browser window[^](without receiving the "Do you want to close this window" prompt?)
 
Share this answer
 
<a href="javascript:self.close()">Close the window</a>


or,-
<script language="JavaScript" type="text/javascript">
function closeW()
{
window.opener = self;
window.close();
}

</script> 
 
Share this answer
 
Hey Sonia,
You might not know that in which browser you application accessed by user so you can have this script.
it will taken care of IE8,7,6 and Firefox.

if ((userBrowser.browser == "Explorer" && (userBrowser.version == "8" || userBrowser.version == "7")))
{
window.open('', '_self', '');
window.close();
}
else if ((userBrowser.browser == "Explorer" && userBrowser.version == "6"))
{
window.opener = null;
window.close();
}
else
{
window.opener = '';
window.close();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900