0
votes

I want to close the current browser tab via javascript in asp.net. So for this i am using window.close() method and its working fine. But the main issue is that if I opened a new asp.net page on same tab by using right click menu then "close" button is not closing current tab.

Close button and script both are on "Master page".

1
Do you mean that if you create another tab and then call window.close() it's not closing the original tab? - Luke
On the same tab, if i redirect new asp.net page and click on close button then its not closing this tab. - prakash menaria
and which is closing??? the new one??? - lem2802
I think you have't got my issue. If I opened new page on same tab like on existing tab then browser tab is not closed by client side javascript. - prakash menaria

1 Answers

0
votes

Try this:How close current window tab in all browsers using javascript.

Taken from :https://raghunathgurjar.wordpress.com/2012/05/02/how-close-current-window-tab-in-all-browsers-using-javascript/

< script >
function closeMe()
{
var win = window.open(“”,”_self”); /* url = “” or “about:blank”;       target=”_self” */
win.close();
}
< /script >
< input type=”button” name=”CloseMe” value=”Close Me” onclick=”closeMe()” />`