close the window

Posted by Saravanan05 under JavaScript on 1/22/2010 | Views : 1680 | Status : [Member] | Replies : 6
hi friends

i want to close the browser window using javascript;

i used window.close()-it is working fine,but alert message is displayed..

i am not necessary alert message is popup



can any one help me?

Regards
Saravana
coimbatore(Manchester of south india)
Tamil Nadu




Responses

Posted by: Abhi2434 on: 1/23/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
No sagarp, when you use

window.close() it will prompt you with an alert in most of the browsers.

Use this code

javascript:window.opener='self';window.close();

placing window.opener to self will ensure that the window closes without the confirm dialog.

:)


www.abhisheksur.com

Saravanan05, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RtpHarry on: 1/23/2010 [Member] [MVP] Bronze

Up
0
Down
I think that the issue causing the "are you sure" message is that the window.close() call must be user initiated.

what i mean is that if you put it in a link like Sagar has then it should work.

if you put it in the page load script like so you can pop up a box, do something and immediately close the window it will say are you sure.


Im dont know if abhi's code would work as a solution to this issue?

Saravanan05, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kumarsudu on: 1/25/2010 [Member] Starter

Up
0
Down
Hi,

User
self.close()


it will close the window without any prompt message


Thanks and Regards,
Kumar

Saravanan05, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 1/25/2010 [Member] Bronze

Up
0
Down
Saravanan,

There is a trick to do that. You can try with the following. Kindly let me know if it resolves the issue.

function winclose() {

window.opener = top;
window.close();
}


Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Saravanan05, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rcsprakash on: 1/28/2010 [Member] Starter

Up
0
Down
use
<script>window.close()</script>
if the window in tabbed think it will show the alert.


Saravanan05, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarp on: 1/23/2010 [Member] Bronze

Up
0
Down
hi

use this code
<a href="JavaScript:window.close()" >Close this Window</a>

thanks

sagar

Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

Saravanan05, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response