如何在html标签中使用vbs变量 [英] how to use vbs variables in html tags

查看:179
本文介绍了如何在html标签中使用vbs变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个hta应用程序,我试图添加一个选项来更改配色方案。我一直在试图在标签中使用一个变量。例如:Color1而不是黑色等。
但是,一切都只是默认的颜色



这是我在vbs部分写的部分:

  Sub changecolor 
Colorbutton = gray
Colorbuttontext = black
Colortextbox = black
Colortext = aqua
End sub

以下是我有HTML的snippit:

 < input type =textcolor =Colortext> 
< input type =buttoncolor =Colorbutton>

我已经有一个使用onChange =changecolor的下拉菜单,知道它到达sub



我试过把Colortext.value或Colorbutton.value,但一切仍然改变为默认的颜色。



如果有人知道如何解决这个问题,请告诉我,谢谢!



Ps我是一个新手,所以如果你可以保持答案愚蠢,这将是太棒了,再次感谢 需要使用DOM API来操作网页,元素的视觉外观由CSS控制,尽管一些传统的表示属性仍然有效(例如< body background> ) 。



我推荐在所有可能的情况下使用基于VBScript的JavaScript,而不仅仅是为了表达更多的语法,而且还需要更大的灵活性和编程选项,与VBScript的有限的输入系统相比,它可以提供基于文本的本质。

您可以像使用VBScript一样在HTA中使用JavaScript,只需使用< script type = text / javascript> 而不是< script language =VBScript>



请注意,您无法在HTA中可靠地使用边缘模式,因此过去几年中浏览器的新发展将无法正常工作巧妙的,如新的CSS3效果或DOM更改。当你处于边缘模式时,HTA特定的标记将被HTA shell忽略,所以你不能在边缘模式下设置自定义窗口图标或标题栏文本(我觉得这是一个错误,但AFAIK微软没有计划修复)

在JavaScript中,您可以这样做:

 < script type =text / javascript> 
window.onload = function(){
var colorButton = document.getElementById(colorButton);
colorButton.onclick = function(){
var textInput = document.getElementById(textInput);
textInput.style.color =black; //前景(文字)颜色
textInput.style.backgroundColor =blue;
};
};
< / script>

< input type =textid =textInput/>
< button id =colorButton>点击我< /按钮>


I'm making an hta app and I'm trying to add in an option to change the color schemes. I've been trying to use a variable in the tag. ex:Color1 instead of black etc.. But everything is just default colors

Heres part of what I wrote in the vbs section:

Sub changecolor    
Colorbutton = gray    
Colorbuttontext = black    
Colortextbox = black    
Colortext = aqua    
End sub    

Here's a snippit of the HTML I have:

 <input type="text" color="Colortext">     
 <input type="button" color="Colorbutton">     

I already have a drop down menu that uses onChange="changecolor" and I've tested and I know its getting to the sub

I've tried putting Colortext.value or Colorbutton.value, but everything still changes to the default colors. Does the tag not recognize the variable so it Just skips it reverts to the default colors?

If anyone knows how to fix this let me know, thanks!

P.s. I'm kindof a novice so if you could keep the answers as dumb as possible that would be fantastic, thanks again

解决方案

You need to use the DOM API to manipulate a webpage, and the visual appearance of elements is controlled by CSS, though some legacy presentational attributes still work (e.g. <body background>).

I recommend using JavaScript over VBScript in all cases where possible, not least for the more expressive syntax, but also for the greater flexibility and programming options enabled by its prototype-based nature, compared to VBScript's limited typing system.

You can use JavaScript in a HTA just like VBScript, just use <script type="text/javascript"> instead of <script language="VBScript">.

Note that you cannot use reliably use "Edge mode" in HTAs, so new developments in browsers over the past few years will not work reliably, such as new CSS3 effects or DOM changes. When you are in Edge mode, HTA-specific markup will be ignored by the HTA shell, so you cannot set a custom window icon or titlebar text while in Edge mode (I feel this is a bug, but AFAIK Microsoft has no plans to fix this).

In JavaScript, you would do it like this:

<script type="text/javascript">
window.onload = function() {
    var colorButton = document.getElementById("colorButton");
    colorButton.onclick = function() {
        var textInput = document.getElementById("textInput");
        textInput.style.color = "black"; // foreground (text) color
        textInput.style.backgroundColor = "blue";
    };
};
</script>

<input type="text" id="textInput" />
<button id="colorButton">Click me</button>

这篇关于如何在html标签中使用vbs变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆