VBScript set value at onload

别说谁变了你拦得住时间么 提交于 2019-12-13 02:25:04

问题


I have an HTA with VBScript that has an element set to a variable, SN2:

<script language="VBScript">document.getElementById("ComputerName").value = SN2</script>

Set to print out to an HTML textbox:

<html><input class="inputs" type=text id="ComputerName" name=ComputerName /></html>

And this works well! However, I wanted to set the value to display in the textbox on onload

To do this, I set my VBScript function to <body onload="myFunction()">. And this works well, except there is another function I need to set to body onload

So I was wondering if there was a way to set my document.getElementById("ComputerName").value = SN2 to onload in a different way.

I know the way in javascript, like you can set document.getElementById("ComputerName").onload, but that doesn't seem to be working in VBScript. Can this be done in VBScript, and if so, how? I can't use javascript for my case. I'm referring specifically to this method (although I don't need any of that iframe stuff they have in this example). For some reason this JS way doesn't translate in VBScript.

Thanks for any input!


回答1:


You can call many functions onload:

<BODY onLoad="firstFunction();secondFunction() ">


来源:https://stackoverflow.com/questions/29396210/vbscript-set-value-at-onload

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