Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA close button

Status
Not open for further replies.

dexeloper

Programmer
Oct 26, 2004
162
GB
This is my HTA code:

<head>
<title>test close</title>
<HTA:APPLICATION APPLICATIONNAME="close" SCROLL="yes" SINGLEINSTANCE="yes" WINDOWSTATE="normal">
</head>
<body>
<input type="button" value="close" onClick="closeWin">
</body>
<script language="VBScript">
Sub closeWin
self.close()
End Sub
</script>

When I click the close button I keep getting:
'Object doesn't support this property or method'
at the line containing the button.
Any ideas?
 
i've no experience with VBScript, but is there a reason you are using this to close a window?

why don't you just use
Code:
<input type="button" value="close" onClick="[b]self.close();[/b]">

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Agreed that works but I need to execute subroutines fom buttons for other reasons and don't understand the error.
 
this might work...
Code:
<input type="button" value="close" onClick="closeWin[b]();[/b]">

you'd need to ask in the VBScript forum to see if your subroutine is defined correctly as if you were doing it with JavaScript it would be...
Code:
<script type="text/javascript">
function closeWin() {
self.close();
}
</script>


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Blimey you're right. It needed brackets. Microsofts info on HTA is incorrect.
Many thanks.
 
no probs, glad i could help :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Actually, the problem with the original code is the position of the script tag. You put the script after the code the line calls it, so closeWin is not yet defined when the interpreter first sees it. If you move the script up into the document's HEAD section, it works as expected.
 
hmm you're right too.
I get the feeling not many people use HTA. It looks promising but when you get into it, rather limited.
 
I do not think the location of the call in the page makes any difference. If you were just executing the call directly within your script block then the function would have to already have been defined. But you are calling the function from your HTML which has to be rendered first and by that time all of the functions have been declared.

I have worked a bit with HTA. It is very useful for some things. Remember that you can use Javascript as readily as VBScript.



At my age I still learn something new every day, but I forget two others.
 
does using VBScript not limit your user to IE only browser?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
It would but in this case he is creating an HTA application which operates at the desktop, not from the web and makes use of the IE components already on the system. So in this case it would be a Windows only solution using Explorer.

HTA applications use HTML, Javascript, VBScript just like any web page but they only open in a partial browser window. You get no address or toolbars, just an empty window that you can run your code in.
The benefit is that you can run all of the code with local account privledges and do things like access the network, registry or local resources.

At my age I still learn something new every day, but I forget two others.
 
cool, not heard of this HTA before, another thing to add to my list to check out

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top