Thursday, October 20, 2011

How to close the current tab in the browser in

For this post, I am really thankful to Mr. K.Kathiravan, for finding the solution for closing the current tab of the browser with asking any confirmation. I need to close the current tab (if only one tab open then need to close the browser) while user click on a link (take an example of log out). I also do not want any confirmation message before closing that, since our requirement is to close the browser in any case.

Here is the code that I have written in the page load and it works for me.
Response.Write("<script language='javascript'>'','_self');window.close();</script>");