locked
How to close HTA exe programatically RRS feed

  • Question

  • User1139447206 posted

    Hi ,

    We are using HTA file in one of our legacy application.we are saving the file to exe and performing all operations as browser.

    Here I am using below code to close the HTA file on click of button in code behind file,

    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.close()", true);

    But this is not closing the application and just showing a blank screen which is understandable as it is running as an exe.

    Is there any way to close HTA file programatically ?

    Thanks,

    Raghu.

    Wednesday, May 13, 2020 8:58 AM

All replies

  • User1139447206 posted

    I am able to close the HTA file from javascript with out any issues

    <input type="button" onclick="window.close();" value="Close this window" id="Button1" name="Button1">

    Regards,

    Raghu.

    Wednesday, May 13, 2020 10:23 AM
  • User1535942433 posted

    Hi RaghuMasineni,

    Accroding to your description,as far as I think,you could use window.open('close.html', '_self', null);

    More details,you could refer to below codes:

    <head>
        <meta charset="utf-8" />
        <title></title>
        <script language="javascript" type="text/javascript">
            var redirectTimerId = 0;
            function closeWindow() {
                window.opener = top;
                redirectTimerId = window.setTimeout('redirect()', 2000);
                window.close();
            }
    
            function stopRedirect() {
                window.clearTimeout(redirectTimerId);
            }
    
            function redirect() {
                window.location = 'WebForm37.aspx';
            }
        </script>
    </head>
    <body onload="closeWindow()" onunload="stopRedirect()" style="">
        <center><h1>Please Wait...</h1></center>
    </body>
        protected void Button1_Click(object sender, EventArgs e)
            {
                ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.open('close.html', '_self', null);", true);
            }

    Best regards,

    Yijing Sun

    Thursday, May 14, 2020 6:31 AM