如何从html调用vbscript函数? [英] How can I call a vbscript function from html?
本文介绍了如何从html调用vbscript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我到目前为止所拥有的.我正在尝试使用IE进行用户输入.我需要帮助的是应该被称为myfunc()的"OnClick"东西.
This is what I have so far. I'm trying to use IE for user input. All I need help with is the 'OnClick' thing that is supposed to be calling myfunc().
'global variables
Dim objIE, screen, w, h
GetClient
'==============================================SUBS AND FUNCTIONS BELOW=================================================
Sub GetClient
Set objIE = CreateObject("InternetExplorer.Application")
set screen = ObjIE.Parent
w = screen.width
h = screen.height
'make IE look like an input box kinda
objIE.Navigate("about:blank")
objIE.Document.Body.Style.overflow = "auto"
objIE.document.title = "--------------------BITB Client--------------------"
objIE.visible = true
objIE.MenuBar = False
objIE.ToolBar = False
objIE.AddressBar = false
objIE.Resizable = False
objIE.Width = 400
objIE.Height = 280
objIE.Left = (w/2) - 200
objIE.Top = (h/2)
'html form to get input
objIE.Document.Body.InnerHTML = "<p>-Please choose a client listed below-</p>" _
& "<form>" _
& "<input type=""radio"" name=""client"" value=""176"">176<br>" _
& "<input type=""radio"" name=""client"" value=""515"">515<br>" _
& "<input type=""radio"" name=""client"" value=""760"">760<br>" _
& "<input type=""submit"" value=""submit"" OnClick=""VBScript:myfunc()"">" _
& "</form>"
end sub
function myfunc()
msgbox "yay it works"
end function
我到处都看过,但我不明白为什么这行不通.如果有人可以帮助,将不胜感激. =].同样,如果有人想让该功能可以告诉您选择了哪个单选按钮,就可以继续进行.
I've looked everywhere and I don't understand why this doesn't work. If anyone could help it would be greatly appreciated. =]. Also if anyone feels like making the function that could tell which radio button was selected go right ahead.
推荐答案
将代码更改为以下内容:
Change your code to something like this:
'global variables
Dim objIE, screen, w, h
GetClient
Do While objIE.document.All.OK.Value = 0
WScript.Sleep 200
Loop
myfunc
objIE.Quit
'==========================SUBS AND FUNCTIONS BELOW==========================
Sub GetClient
Set objIE = CreateObject("InternetExplorer.Application")
...
objIE.Top = (h/2)
'html form to get input
objIE.Document.Body.InnerHTML = "<p>-Please choose a client listed below-</p>" _
& "<!--form-->" _
& "<input type=""radio"" name=""client"" value=""176"">176<br&g;" _
& "<input type=""radio"" name=""client"" value=""515"">515<br>" _
& "<input type=""radio"" name=""client"" value=""760"">760<br>" _
& "<input type='hidden' id='OK' value='0'>" _
& "<input type=""submit"" value=""submit"" OnClick=""VBScript:OK.Value=1"">" _
& "<!--/form-->"
end sub
function myfunc()
msgbox "yay it works"
end function
这篇关于如何从html调用vbscript函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文