Loading...


bookmark - Javascript Close Window Javascript close window

Javascript Close Window - Javascript close window

 
 Discussion by someguy with 26 Replies.
 Last Update: December 16, 2011, 11:48 pm ( View Rated (14) )
 
bookmark - Javascript Close Window Javascript close window  
Quickly Post to Javascript Close Window Javascript close window w/o signup Share Info about Javascript Close Window Javascript close window using Facebook, Twitter etc. email your friend about Javascript Close Window Javascript close window Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Hi does anyone have a code to close the browser window. This code needs to be used to close an actual full sized window, not a pop-up window.











   Thu Nov 3, 2005    Reply         

Try this:

CODE

<a href="javascript:window.close()">Close this window!</a>


I think it's the same regardless of what size the window is.

   Thu Nov 3, 2005    Reply         

In some browsers, closing a top-level window via JavaScript's window.close() will result in a confirmation dialog being displayed. That I know of, this cannot be prevented through the code itself (you may be able to disable it in some browsers, though). Only new windows opened from within that window may be closed without confirmation. Other browsers, however, will simply close the window, no questions asked; it just depends on the respective JavaScript engine and how the developers have opted to handle such an event by default.







   Thu Nov 3, 2005    Reply         


I agree with Spectre. Browsers like Internet Explorer will display a pompt first before closing the window. You should consider those who visit your site and what browser they're using. :P

   Thu Nov 3, 2005    Reply         

hi,

yeah, Internet Explorer always prompts for confirmation before closing the main window. I m not sure of other browser but I suppose most would.

But I visited a certain site where on logging out, the particular window closed and opened a new browser window with a link 'Close this window'. On clicking the link the window closed without any confirmation dialog box. In effect this closed the main window without any dialog box. I m not sure how it was done.. I do not have the site bookmarked too so that I can check it out again..

Did nyone else come across this sort of situation? If nyone knows the solution please post it here.

Cheers.

   Thu Nov 3, 2005    Reply         

There is a way to get around the confirmation problem, simply by instructing the browser that the window was actually opened with javascript, regardless of whether the window was or not.

CODE


function NoConfirm ()
{
win = top;
win.opener = top;
win.close ();
}


Now replace:

CODE


<a href="javascript:window.close()">Close this window!</a>


...with...

CODE


<a href="javascript:NoConfirm()">Close this window!</a>


and it should work. Feel free to ask if it doesn't!

   Thu Nov 3, 2005    Reply         


Ah, very good, rvalkass. It does indeed work. I didn't know it was possible with Internet Explorer at all. And that is why client-side scripting languages are not my area.

   Thu Nov 3, 2005    Reply         

<a href="javascript:window.opener='x';window.close();">Close me</a>

   Tue Oct 2, 2007    Reply         

Thank you for your suggestion.

-CHMOKARAT

   Tue Oct 23, 2007    Reply         

I used the code given here. But somehow its not working. I duno what I missed out! Pls help me.



My Code:

<input type="button" value="Click To Proceed" onclick="javascript: myClose();" class="submit">







-Arthy

   Tue Oct 30, 2007    Reply         

To close the window you use this

Code:
<a href="javascript:window.Close()">YourText</a>

-reply by THITE

   Sat Jan 19, 2008    Reply         

javascript close window code
Javascript Close Window

Replying to rvalkass

Okay, I tried it and it didn't work. To be fair, I put your script in the last window of the sequence that began with a pop-up, but I still don't see why it shouldn't work.

Here's the url:
Http:/catepotyendesigns.Com

Click on "samples"

This opens a slideshow (as a pop-up). The last page (samples15.Html) includes your code

It doesn't close this window

Paul@paulpotyen.Com

-reply by paul Potyen

   Fri Feb 1, 2008    Reply         

If not try:

Javascript:close('window')

Gets message come up with this site is trying to close the page tho!

   Tue Feb 5, 2008    Reply         

Hi, I have a question.

I don't use the button or link to close the window, but really click the close icon of the window, but I want they confirm before close the window, if not confirm the window should still open . How to implement it ?

   Mon Mar 10, 2008    Reply         

Replying to Trap FeedBacker
Javascript Close Window

Try this:

<form method="post">
<input type="button" value="Close Window"
Onclick="window.Close()">
</form>

-reply by Mark

   Sun Jun 8, 2008    Reply         

Why javascript: window.close () is not working in Fire Fox, Is there any solution?
Javascript Close Window

Why javascript: window.Close () is not working in Fire Fox, Is there any solution?



-reply by Samuel

   Wed Jul 16, 2008    Reply         

php close windowJavascript Close Window

awesome rvalkass, I spent several days to look for the right way to do this thing and your code is seemingly the only one I found

appreciated!

 

-reply by Author Name - e.G. John, MikeKeywords: php close window

   Thu Feb 26, 2009    Reply         

none of these examples work on ff 3. So far I have not seen anyway to close a window not opened by a opener link, in firefox 3. Just ain't happening.

-reply by George W

   Wed Apr 1, 2009    Reply         

Closing all tabs in IE7Javascript Close Window

when the user logs out my application - I display a page with a close button (and I use window.Close()).

But when the user clicks on that button - I need to close all the tabs - in otherwords close IE7 itself.

Is there a javascript code to do that.

thanks in advacen 

-question by Nathan

 

   Thu May 7, 2009    Reply         

Firefox?Javascript Close Window

None of theses close window codes work in the newest firefox (version on the date I wrote this).

I'm creating a kiosk desktop with interactive visual effects an I've stabbed ubuntu desktop with

many radical blaablaablaa...

I have icons that open product info pages(html) on firefox and I have hidden all the borders and menus etc, I'd like to close these windows somehow..

- Can anyone help with this??

-reply by Pete Vuan

   Thu Oct 15, 2009    Reply         

Hi

I want to close the current window forcefully without any cinfirmation message.

Please help me >>>>>

Thanks and Best Regards

Hardeep Singh Bhullar

 

 

 

   Tue Mar 2, 2010    Reply         

None of these examples work for Firefox 3, Chrome 5, or Safari 5.

   Thu Jul 22, 2010    Reply         

Definately it will work in firefox. try this code

CODE

function closewindow() {
var answer = confirm("Are you sure want to close this window ?");
if (answer){
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
window.close();
}
else{
stop;
}
}

QUOTE (iGuest)


Why javascript: window.close () is not working in Fire Fox, Is there any solution?
Javascript Close Window

Why javascript: window.Close () is not working in Fire Fox, Is there any solution?



-reply by Samuel

Link: view Post: 399866

   Wed Nov 10, 2010    Reply         

QUOTE (Kamlesh)


Definately it will work in firefox. try this code

CODE

function closewindow() {
var answer = confirm("Are you sure want to close this window ?");
if (answer){
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
window.close();
}
else{
stop;
}
}


Link: view Post: 499036


For this to work we need set change permission on our local browser. This isnt feasible as we cant ask the users of our web application change their security settings. Is there any other solution?

   Mon Feb 14, 2011    Reply         

QUOTE (Antony)


For this to work we need set change permission on our local browser. This isnt feasible as we cant ask the users of our web application change their security settings. Is there any other solution?

Link: view Post: 502560


Hi Friends,

Any one got any update on this thread?
How to close the current window in Firefox(3.6.15)?
The window.close() is not working...

netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
window.open(,'_self');
window.close(); unable to trigger force close.

Detecting browser closes in IE and FireFox :D

I incorporate it in my JScript.js and when i use it in a big project and call the javascript function ForceCloseWindow() it did not work :c Error message of e.toString() states that 'A script from "http:" was denied UniversalBrowserWrite privileges.'

My question follows. How can I programmatically enable UniversalBrowserWrite privileges.


Thank you. Please advise.

Chandru P

   Tue Mar 8, 2011    Reply         

Hi Friends.

Is there any way i can close all related tabs or windows

window.close() only close the current window or tab but i need to close all the tabs related to that application if they opened.

if they right click on any link and opened in new tab when logout i need to close the other one to

Any please appreciated

   Wed Nov 30, 2011    Reply         

QUOTE (someguy)


Hi does anyone have a code to close the browser window. This code needs to be used to close an actual full sized window, not a pop-up window.

Link: view Post: 201018


SO frustrated with newer browsers being what I assume is secure... or not. On this topic, the only 'solution' I've found is this: make sure the page was opened using JavaScript or even a link ( a href ). This WILL close full-size windows/tabs.

After trying every suggestion in this thread (thank you all for taking the time!), I found that only by opening a window/tab via a link/JS was I able to get the *.close() functionalities to work.

Grr.
David

   Fri Dec 16, 2011    Reply         

Quickly Post to Javascript Close Window Javascript close window w/o signup Share Info about Javascript Close Window Javascript close window using Facebook, Twitter etc. email your friend about Javascript Close Window Javascript close window Print
Reply / Comment New Discussion / Topic Share / Bookmark E-Mail a Friend Print

Similar Topics:

Javascript Window.open

When I try to run the following code in Internet Explorer I get an "Invalid argument" error but it works fine on Firefox CODEwindow.open("users/ve_edit.php","edit av","toolbar=no,location=no,directories=no,status=no,sc rollbars=no,resizable=no,copyhis ...more

   06-Jun-2005    Reply         

Close Webpage If User Goes To Anoth...

I have one html page, I replace it using Javascript to another, after checking if client browser is IE 6+ or not. I have the html page, first.hml: CODE<HTML> <HEAD> <TITLE>MyFirstPage</TITLE> </HEAD> & ...more

   14-Oct-2005    Reply         

Do You Close The Javascript?

hi folks i'm learning that the javascript and cookies sometimes leak your real ip and actions on surf , some expert advice me close javascript ,stop the function of my opera and IE. so i did.then everytime i log into a forum i need opend it manually so i can log in. ...more

   28-Apr-2008    Reply         

Fill Jcombobox    Fill Jcombobox (1) (1) Button To Display An Image   Button To Display An Image