Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a window using jQuery

How to close a window using jQuery for all browser compatibility?

<input type="button"         name="backButton"         value="Close"         style="background-color:#245f91; color:#fff;font-weight:bold;"         onclick="window.close();"> 

This onclick event is working in IE. Could you help me to write code in jQuery?

like image 381
surya Avatar asked Jan 17 '12 06:01

surya


People also ask

How do I close a tab in jquery?

window. top. close(); this will close the current tab for you.

How do I close a window in JavaScript?

Simply call window. close() and it will close the current window.

How do I close a current window?

Press Alt + F4 to close a window.


1 Answers

$(element).click(function(){     window.close(); }); 

Note: you can not close any window that you didn't opened with window.open. Directly invoking window.close() will ask user with a dialogue box.

like image 91
Shiplu Mokaddim Avatar answered Sep 20 '22 21:09

Shiplu Mokaddim