Javascript in HTA File

僤鯓⒐⒋嵵緔 提交于 2021-02-08 04:10:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!