<Script language = "javascript" type = "text/javascript">
Function getconfirm ()
{
If (confirm ("do you want to disable it? ") = True)
{
Window. close ();
Return true;
}
Else
{
Return false;
}
}
</Script>
<Asp: Button ID = "Btn_Close" runat = "server" Text = "close" Width = "103px" OnClick = "Btn_Close_Click" OnClientClick = "return getconfirm ()"/>
In this case, when you click the close button, "Do you want to close it?" will pop up ?" But when you click "yes", another message box "the page you view is attempting to close the tab. Close the tab ?".
Here is a solution:
<Script language = "javascript" type = "text/javascript">
Function getconfirm ()
{
If (confirm ("do you want to disable it? ") = True)
{
Window. open ('', '_ parent ','');
Window. top. opener = null;
Window. close ();
Return true;
}
Else
{
Return false;
}
}
</Script>
<Asp: Button ID = "Btn_Close" runat = "server" Text = "close" Width = "103px" OnClick = "Btn_Close_Click" OnClientClick = "return getconfirm ()"/>
In this way, the current tab is closed directly, and another message box is no longer displayed.