admin管理员组文章数量:1289363
I'm trying to access a variable in javascript that i set in vbscript all within one hta file:
<script type="vbscript">
var globalVariable = test123
</script>
<script type="text/javascript">
var globalVariable = <%= globalVariable %>;
</script>
This doesn't populate the variable globalVariable with anything. I've also tried
var globalVariable = "<%= globalVariable %>";
This just populates the string within the quotes into the variable globalVariable.
I can't get the value 'test123
' set in the VBScript section to populate into a JS variable within the JS section.
Any help would be appreciated.
I'm trying to access a variable in javascript that i set in vbscript all within one hta file:
<script type="vbscript">
var globalVariable = test123
</script>
<script type="text/javascript">
var globalVariable = <%= globalVariable %>;
</script>
This doesn't populate the variable globalVariable with anything. I've also tried
var globalVariable = "<%= globalVariable %>";
This just populates the string within the quotes into the variable globalVariable.
I can't get the value 'test123
' set in the VBScript section to populate into a JS variable within the JS section.
Any help would be appreciated.
Share Improve this question edited Dec 23, 2011 at 21:16 Vimal 1,2661 gold badge9 silver badges16 bronze badges asked Dec 23, 2011 at 21:06 szdmgdevszdmgdev 211 gold badge2 silver badges3 bronze badges3 Answers
Reset to default 4Based on your question, I've written an HTA containing the following code:
<script type="text/vbscript">
dim globalvariable
globalvariable = "test123"
</script>
<script type="text/javascript">
alert(globalvariable);
</script>
and the value "test123" is displayed in the alert box.
Note the following differences with your code:
- vbs language syntax is different to js syntax;
- your js code looks like asp code to me, rather than js;
- I got an error message using '' without 'text/' prefix;
Mixing languages in a .HTA App is easy, if you just follow the syntactical rules for each language (e.g. there is no "var" in VBScript).
<html>
<head>
<hta:application id = "mix"></hta>
<script LANGUAGE="VBScript">
Dim gsX : gsX = "global VBScript variable"
</script>
<script LANGUAGE="JScript">
alert(gsX);
</script>
</head>
<body>
</body>
</html>
Can you use a DOM element like a hidden input field to municate between VBScript and JS? If that works you can trigger a custom event when the value changes, and listen for that event on both sections.
I never used VBScript before so this may not be possible.
本文标签: Access VBScript variable within Javascript inside of an HTAStack Overflow
版权声明:本文标题:Access VBScript variable within Javascript inside of an HTA - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741446612a2379239.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论