如何通过 vb.net Webbbrowser 控件更改值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14535333/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change value via vb.net Webbbrowser control
提问by Haytham Mtair
Starting with this navigation call:
从这个导航调用开始:
Webbrowser.Navigate("localhost")
the Webbrowser.Documentobject holds a ref. to a HTML object with the following attributes:
该Webbrowser.Document对象持有一个引用。到具有以下属性的 HTML 对象:
id="first"
name="first"
type="text"
value="something"
My question is; How do I change the value?
我的问题是;如何更改值?
I have seen some posts about how to get the element via getElementById:
我看过一些关于如何通过getElementById以下方式获取元素的帖子:
Webbrowser.Document.getElementById("first")
But i still have no idea how to change its value.
但我仍然不知道如何改变它的value.
回答by Haytham Mtair
I found it:
我找到了:
Webbrowser.Document.getElementById("user").setAttribute("value", "username")
Or if the element has no id:
或者如果元素没有id:
Webbrowser.Document.getElementByTagName("input").getElementByName("user").item(0).setAttribute("value", "username")

