设置跨度的主体等于变量

时间:2021-06-03 22:33:14

I'm doing some testing with HTA's and I've come across a problem. Here is the code I am using:

我正在用HTA进行一些测试,我遇到了一个问题。这是我正在使用的代码:

<script language="VBScript">
Public Game

Sub window_onload()
    Game="Help"
    sGame.body.InnerHTML=Game
    sName.body.InnerHTML=Game
End Sub

Sub strTest
    Game="Test"
End Sub
</script>

<body bgcolor="#42732D">

<div style="position:relative;
    text-align:center;
    top:45px;">

<span id = "sName" style="text-align:center;
    font-family:Small Fonts;
    font size:65px;
    z-index:1;
    color:#1C2433"
>

Yes

</span>

<span id = "sGame"
style="text-align:center;
position:absolute;
left:-4px;
font-family:Small Fonts;
font size:65px;
z-index:15;
color:#1094AF"
>
</span>
</div>

<input type="button" style="font-family:Small Fonts; font size:30px; color: white; background-color:grey" value="Testing" name="bTest" onclick="strTest">
</body>

What I'm trying to do is set two spans equal to the same variable (a hack to give the text a 3D look with separate colors) However, when I run strTest, which should change the spans from "Yes" to what the variable Game is equal to, nothing happens. How can I dynamically change the text of a span using a variable?

我要做的是设置两个等于相同变量的跨度(一个黑客为文本提供一个具有不同颜色的3D外观)但是,当我运行strTest时,应该将“跨度”从“是”更改为变量变量游戏等于,没有任何反应。如何使用变量动态更改跨度的文本?

1 个解决方案

#1


1  

<span>s don't have a body property. Just use innerHTML.

s没有body属性。只需使用innerHTML。

Change:

更改:

Sub window_onload()
    Game="Help"
    sGame.body.InnerHTML=Game
    sName.body.InnerHTML=Game
End Sub

To:

至:

Sub window_onload()
    Game="Help"
    sGame.innerHTML = Game
    sName.innerHTML = Game
End Sub

Here's the documentation for the HTMLSpanElement on Mozilla's site. As you can see, it doesn't define any properties. If you work your way up the hierarchy to Element, you'll see the innerHTML property.

这是Mozilla网站上HTMLSpanElement的文档。如您所见,它没有定义任何属性。如果您按层次结构向上工作,则会看到innerHTML属性。

#1


1  

<span>s don't have a body property. Just use innerHTML.

s没有body属性。只需使用innerHTML。

Change:

更改:

Sub window_onload()
    Game="Help"
    sGame.body.InnerHTML=Game
    sName.body.InnerHTML=Game
End Sub

To:

至:

Sub window_onload()
    Game="Help"
    sGame.innerHTML = Game
    sName.innerHTML = Game
End Sub

Here's the documentation for the HTMLSpanElement on Mozilla's site. As you can see, it doesn't define any properties. If you work your way up the hierarchy to Element, you'll see the innerHTML property.

这是Mozilla网站上HTMLSpanElement的文档。如您所见,它没有定义任何属性。如果您按层次结构向上工作,则会看到innerHTML属性。