javascript - 使用 HTML 表单作为 GUI PowerShell 时出现 innerHTML 错误
问题描述
下面的代码工作正常,但是,在 Azure VM 上使用它时出现错误
=============错误==============
Error-
The property 'innerHTML' cannot be found on this object. Verify that the
property exists and can be set.
At line:24 char:1
+ $ie.document.body.innerHTML = $html
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
***
=================代码=================
$html = @"
<HTML>
<body>
<form>
First name: <input type="text" id="firstname">
<br>
Last name: <input type="text" id="lastname">
<br>
<input type="hidden" name="finished" value="0">
<input type="button" id="button" value="Continue"onclick="finished.value=1">
</form>
</body>
</html>
"@
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate2("about:blank")
$ie.AddressBar = $false
$ie.MenuBar = $false
$ie.StatusBar = $false
$ie.document.body.innerHTML = $html
$ie.Visible = $true
$doc = $ie.document
while ($doc.getElementByID("finished").value -ne 1) {
start-sleep -m 500
}
$ie.Visible = $false
"You answered:"
$doc.getElementByID("firstname").value
$doc.getElementByID("lastname").value
$ie.quit()
解决方案
推荐阅读
- java - 如何解决a.io.InvalidClassException:org.ejml.data.DMatrixRMaj;本地类不兼容:流 classdesc serialVersionUID
- php - 对嵌套对象应用回调
- vb.net - 我需要把它从一个子改写成一个函数
- dns - Windows Server 2019 - IP 和计算机名称的 Ping 不匹配,但应该匹配
- batch-file - 批量获取重定向输出
- printing - 从桌面上传文本文件时。每次我插入出生日期后,我都会收到此错误
- python - 有序 = True 不被尊重。蟒蛇+棉花糖+烧瓶
- charts - Overlapp Google area图表
- swift - SwiftUI managedObjectContext 在 appExtension 中加载
- python - Python 正则表达式从字符串中获取浮点数对(如果存在)