【发布时间】:2019-04-08 14:32:29
【问题描述】:
我有可以从 HTML 页面读取数据的第 3 方应用程序(已编译)。这是通过创建一个 Internet Explorer 对象并加载一个空页面 (.navigate "about:blank") 来完成的。表单元素通过 Document.Body.innerHTML 添加到页面。当通过 Submit 退出 HTML 页面时,应用程序通过 CreateObject("WScript.Shell") 读取提交数据。我想添加一些 JavaScript 来将输入数据组合成一个字符串。也就是说,输入到输入文本框 1 和输入文本框 2 的数据在文本框 3 中连接或/AND 根据复选框或单选按钮更改文本框 3 中的值。然后我可以将这些值发送回应用程序。如何进一步修改这个空网页以包含 java 脚本来完成上述操作
“g_objIE.Document.Body.innerHTML =”代码运行良好。它非常基础,只包含表单元素。我可以简单地将java脚本添加到innerHTML吗?我不这么认为。我尝试添加非常基本的代码并收到“预期语句结束”错误。我试图插入: "
" & _ " document.getElementById("demo").innerHTML = 5 + 6; "& _这是工作代码。
' First step, set up the dialog (InternetExplorer)
Set g_objIE = CreateObject("InternetExplorer.Application")
g_objIE.Offline = True
g_objIE.navigate "about:blank"
g_objIE.document.focus()
' Wait for the navigation to the "blank" web page to complete
Do
crt.Sleep 900
Loop While g_objIE.Busy
g_objIE.Document.body.Style.FontFamily = "Sans-Serif"
' Here's where we "create" the elements of our dialog box. We basically
' throw HTML into the document, and IE loads it in real-time for us.
'
' The hidden "ButtonHandler" input is used to tie IE and
' SecureCRT together such that SecureCRT can know when a
' button is pressed, etc.
g_objIE.Document.Body.innerHTML = _
"<input type=radio name='LogMode' value='Append' AccessKey='A' checked>fpeth.3125 / Access" & _
"   " & _
"<input type=radio name='LogMode' value='Overwrite' Accesskey='w' >fpeth.3070 / Core<br>" & _
"<hr>" & _
"<b>Path/File</b> <input name='fName' size='60' maxlength='60' tabindex=1><br>" & _
"<b>HOST</b> <input name='tID' size='30' maxlength='30'><br>" & _
"<hr>" & _
"<button name='Cancel' AccessKey='C' onclick=document.all('ButtonHandler').value='Cancel';><u>C</u>ancel</button>" & _
"<input name='ButtonHandler' type='hidden' value='Nothing Clicked Yet'>"
g_objIE.MenuBar = False
g_objIE.StatusBar = True
g_objIE.AddressBar = False
g_objIE.Toolbar = False
g_objIE.height = 270
g_objIE.width = 510
g_objIE.document.Title = "TCP"
g_objIE.Visible = True
【问题讨论】:
-
"...3rd 方应用程序(已编译)" 请发布预编译/未编译的应用程序。 ATM 这个 OP 看起来像一团糟。
标签: javascript dom innerhtml