C# 使用Windows Phone WebBrowser登录到站点
我正在尝试使用Windows PhoneC# 使用Windows Phone WebBrowser登录到站点,c#,javascript,windows-phone-7,C#,Javascript,Windows Phone 7,我正在尝试使用Windows PhoneWebBrowser登录网站 <form id="loginform" method="post" action="viaJavascript" onsubmit="formSubmit(); return false;"> <h2>Password</h2> <p> <input type="hidden" name="user" maxlength="8
WebBrowser
登录网站
<form id="loginform" method="post" action="viaJavascript" onsubmit="formSubmit(); return false;">
<h2>Password</h2>
<p>
<input type="hidden" name="user" maxlength="8" />
<input type="password" name="pwd" maxlength="29" />
<input type="hidden" name="from" value="/adminweb/jsp/timetables/timetablesController.jsp" />
<input type="hidden" name="query" value="" />
</p>
</form>
我在一个Windows.Form
中成功地完成了这项工作,使用了:
webBrowser1.Document.GetElementById("user").SetAttribute("value", Store_Login.Get_Username());
我知道如何使用
InvokeScript
调用OnSubmit()
,但是如何设置user
和pwd
的值?您可以使用InvokeScript
调用eval
函数。使用此选项执行设置用户名和密码的JavaScript代码:
webBrowser1.InvokeScript("eval", "document.getElementById('name').value = 'username';");
webBrowser1.InvokeScript("eval", "document.getElementById('pwd').value = 'password';");
一个可能的警告是,某些站点会阻止执行
eval
。但听起来你的目标是一个特定的网站。如果可行,请尝试。您可以使用InvokeScript
调用eval
函数。使用此选项执行设置用户名和密码的JavaScript代码:
webBrowser1.InvokeScript("eval", "document.getElementById('name').value = 'username';");
webBrowser1.InvokeScript("eval", "document.getElementById('pwd').value = 'password';");
一个可能的警告是,某些站点会阻止执行
eval
。但听起来你的目标是一个特定的网站。如果可行的话试试。非常感谢,您的代码让我走上了正确的方向webBrowser1.InvokeScript(“eval”,“document.getElementById('loginform1')。user.value='username';”代码>此代码适用于meI需要从此
中获取值“14”每周都会更改请参见我对其他问题的回答;)非常感谢,您的代码让我走上了正确的方向webBrowser1.InvokeScript(“eval”,“document.getElementById('loginform1'))。user.value='username';”代码>此代码适用于meI需要从此
中获取值“14”每周都会更改请参见我对其他问题的回答;)