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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems terminating HTA script

Status
Not open for further replies.

pce0

Technical User
Jan 27, 2004
16
0
0
Hi all,

What is the correct way to cleanly terminate an HTA application/script?

I am using self.close however when doing so in the script below I get an access deined error when rerunning the HTA , I have noticed this only happens with the window.resizeto method (i.e. if this line is removed the error does not occur) - any ideas ?

<html>
<head>
<script language="vbscript">

sub Window_onLoad
window.resizeTo 800,600
end sub

</script>
</head>
<body>
<button STYLE="position:absolute;left:10px;top:500px">Launch Script</button><br />
<button STYLE="position:absolute;left:320px;top:500px" onclick='self.close'>Quit</button><br />
</body>
</html>
 
I had lots of problems with that. Try it this way
Code:
<html>
<head>
<script language="vbscript">
resizeTo 800,600
' Do not add anything else here: it misbehaves sometimes
</script>
<script language="vbscript">
sub Quit_onClick
   Self.Close
   ' or Window.Close
   '    Window.Parent.Close ' You may or may not need this
end sub
</script>
</head>
...

<button STYLE="..." name="Quit">Quit</button>
You can have other scripts after that but just make sure that the resize is the first thing otherwise there is a lot of flashing.

If you specify a name, then just declare an onClick method with the name_ prefix and it will automatically go there.

I don't know the difference between having it inline in HTML and calling an _onclick routine. I haven't gotten crashes since I started using routines so I've just stuck with it.
 
Thankyou for your reply, unfortantley this has not resolved the error :-(

I still get an access denied error referencing the line of the resizeto code.
 
In the hesd section, add an empty tag of hta:application. This tag can take more setting in the form of its attributes, but here you do not have worried about it at the moment.
[tt] <hta:application />[/tt]
 
Tried adding the <HTA:Applicaion> tag but still getting the access denied error...

What is happening is that the script runs, and terminates ok with the self.close, but the access deined error then occurs when I rerun the script.?
 
Are you reasoning according to the script shown or are you taking things for granted that we see through the screen?
 

sorry but I have no idea what you mean by this comment!
 
>when I rerun the script
Script means the whole hta, I suppose?
 
beg your pardon, yes by 'script' I guess I actually mean the HTA application
 
What is the button Launch script for? Is it simplified as such or there are really something associated with it? The problem is I cannot reproduce the problem. As it is a simple script, I guess I am not alone.
 
Yes this is just a cut-down version of the full script. Maybe I have an 'environmental' issue on my test machine then!

Thanks for trying.
 
I'm pretty sure there is no [tt]self[/tt] in VBScript. I think [tt]Me[/tt] is the object you'd want, but I don't see it helping here anyway.

There is a good chance that by using "Javascript event binding" (your "inline" event binding) you're actually defaulting to JScript there and probably have a syntax error.

You might want:

[tt]onclick='self.close()'[/tt]

... but why load both script engines? And why try to "close" the button? More likely:

[tt]onclick='VBScript:window.close'[/tt]


In [tt]window_onload[/tt] I use [tt]resizeTo[/tt] all the time. I don't see a problem with yours.
 
I don't use any VBScript but I close all my HTAs with window.close() with JavaScript... Works fine.

- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
Or, include the hta:application attributes...

Code:
<hta:application
	applicationname="my.hta"	
	border="thick"
	borderstyle="normal"
	caption="true"
	contextmenu="false"
	icon="c:/program files/Microsoft Office/OFFICE11/refbarh.ico"
	maximizebutton="false"
	minimizebutton="false"
	navigable="false"
	scroll="false"
	selection="false"
	showintaskbar="true"
	singleinstance="true"
	sysmenu="true"
	version="1.0"
	windowstate="normal"
>

description in the <head> of your page. This code is just a subset of the attributes.

Take a look at




strebor
 
Hmm. strebor, what does this have to do with closing the HTA?

- Lowet

[gray]Why can't all browsers parse pages the same way? It should be the Web designer who decides how to display the content, not the browser![/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top