读书人

winform中使用webbrowser如何获取html

发布时间: 2013-06-25 23:45:42 作者: rapoo

winform中使用webbrowser怎么获取html中的input(hidden)的value
例如以下html:
<html>
<head>
<title>无标题页</title>

<script src="jquery-1.8.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$("#Hidden1").val("123");
});
</script>
</head>
<body>
<input id="Hidden1" type="hidden" />
</body>
<html>
请问,在winform中使用webbrowser怎么获取html中的input(hidden)的value值

WinForm
[解决办法]
试一下 webbrowser1.Document.GetElementById("Hidden1").GetAttribute("value")
[解决办法]


private void PrintHelpPage()
{
// Create a WebBrowser instance.
WebBrowser webBrowserForPrinting = new WebBrowser();

// Add an event handler that prints the document after it loads.
webBrowserForPrinting.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(PrintDocument);

// Set the Url property to load the document.
webBrowserForPrinting.Url = new Uri(@"\\myshare\help.html");
}

private void PrintDocument(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
// Print the document now that it is fully loaded.
((WebBrowser)sender).Print();

// Dispose the WebBrowser now that the task is complete.
((WebBrowser)sender).Dispose();
}

代码来自msdn:
http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.documentcompleted.aspx

读书人网 >C#

热点推荐