gpt4 book ai didi

javascript - 使用 awesomium 将值提交到 html 文本框 - vb.net

转载 作者:行者123 更新时间:2023-12-02 16:00:44 26 4
gpt4 key购买 nike

我使用此代码从列表框中拆分文本:

For Each Item As Object In ListBox1.SelectedItems
TextBox2.AppendText(Item.ToString + Environment.NewLine)
Next
Dim str As String = TextBox2.Text
Dim leftPart As String = str.Split(":")(0)
Dim test As String = TextBox2.Text
Dim phrase As String = test.Substring(test.IndexOf(":"c) + 1)

这段代码将值提交到html文本框

WebControl1.ExecuteJavascript("document.getElementById('email').value=""" + leftPart + """;")
Dim leftpar2 As String
leftpar2 = phrase
MsgBox(phrase)
Try
WebControl1.ExecuteJavascript("document.getElementById('pass').value=""" + leftpar2 + """;")
Catch ex As Exception
MsgBox(ex.ToString)
End Try

带有 id(电子邮件)的文本框工作正常
但另一个(pass)总是为空,我尝试弹出(phrase)的值,它得到了正确的值

我尝试将字符串分配给变量(短语)

Dim phrase As String = "test"   

它工作正常,有人可以告诉我做错了什么吗?

最佳答案

嗯,我已经下载了该组件并按照您的方式进行了

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (TextBox1.Text.Length < 3 Or TextBox1.Text.IndexOf(":") < 1) Then
MsgBox("Please type value in format like {email:password}")
Return
End If

' Get the values and parse it
Dim sources As String() = TextBox1.Text.Split(":")

' Now, we try to set it to page
' pay attention at `document.querySelector('#id')` it should be ID of the element
WebControl1.ExecuteJavascript(String.Format("document.querySelector('#email').value = '{0}'", sources(0)))
WebControl1.ExecuteJavascript(String.Format("document.querySelector('#password').value = '{0}'", sources(1)))
End Sub

这是我的登录页面代码(在 WebControl 组件中加载的页面)

<body>
<input type="email" id="email" />
<input type="password" id="password" />
<button id="loginButton">Login</button>
</body>

一切似乎都正常

您可以运行我的示例:将文本框、Webcontrol 和按钮放在表单上,​​将 WebControl1.Source 设置为 ' http://cafe-ht.ml/fake/fake-login.html ' 并在按钮单击时复制处理程序

enter image description here

关于javascript - 使用 awesomium 将值提交到 html 文本框 - vb.net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31223155/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com