问题
everytime when i try to add javascript in a hta file with vbscript it comes an error message when i click the submit button:
object doesn't support this property or method
I try this
<script type="text/javascript" src=""></script>
and this
<script type="text/javascript">
...code
</script>
Is there anyone who know the problem?
//EDIT: I have the problem, i forgot a VBScript: to call the vbscript sub THANKS!!
<input type="submit" value=" Submit " onclick="Submit" style="margin-left:100px;">
This is the right one:
<input type="submit" value=" Submit " onclick="VBScript:Submit" style="margin-left:100px;">
回答1:
It's hard to be sure because your question is not complete, however it is likely that you are putting your Javascript code inside VBScripts <script></script>
tags.
'' is like an opening bracket, and '' is like a closing bracket. The VBScript tags are only for VBScript and the Javascript ones are only for Javascript.
Put the following in SILLY.HTA and try it out:
<html>
<head>
<title>My Silly Application</title>
<HTA:APPLICATION>
</head>
<body>
<script language="vbscript">
document.title = "NOT SO SILLY NOW"
self.ResizeTo 200,200
Sub Window_Onload
self.MoveTo (screen.availWidth - (document.body.clientWidth + 40)),10
End Sub
</script>
<script language="javascript">
window.resizeTo(640, 480);
document.write("<h1>Something from Javascript</h1>");
</script>
</body>
来源:https://stackoverflow.com/questions/3158322/javascript-in-hta-file