locked
Closing a HTA from an Iframe RRS feed

  • Question

  • Hello,

    I have a HTA which has a loaded IFrame and I am wondering how I can close the HTA from a button? 

    The end.html is below: 

    <HTML>
    
    <HEAD>
    
    <TITLE>Test</TITLE>
    	
    </HEAD>
    
    <script language = "VBScript">
    
    Sub sbExitHTA()
          Self.Close()
    	  Window.Close()
    End Sub
    
    </script>
    
    <BODY>
    
    <center><H1>Close</H1><br>
    
    <center><img src="Finished.jpg" ></center><br>
    <input type="button" value="Close" onclick="sbExitHTA()">
    
    </BODY>

    When I click on the button it doesn't seem to do anything and Google just seems to suggest that what I am doing is correct. The only difference I can see seems to be that I am using an IFrame.

    Any help would be appreciated.

    Thanks

    Tuesday, December 10, 2019 2:03 PM

All replies

  • "Submit" does not work as expected in an HTA. There is no web with an HTA. An HTA only runs on the local system.

    IFrames do not work in an HTA.


    \_(ツ)_/

    Tuesday, December 10, 2019 5:59 PM
  • I have sorted it out my Iframe works fine I have just used taskkill to kill the HTA when the submit button is clicked.
    Thursday, December 12, 2019 11:16 AM
  • I have sorted it out my Iframe works fine I have just used taskkill to kill the HTA when the submit button is clicked.

    No it doesn't - you have just done something that we warn about. In this case it may not be an issue but killing a process is not a closing an HTA from an iframe. To close from an iframe you need to get the parent object and its window and close that.  In any case you shouldn't use "Submit".  Just use a button.

    Note that HTAs are deprecated as well as VBScript.  You should not really be using it for any new work.


    \_(ツ)_/

    Thursday, December 12, 2019 11:24 AM