namespace GameSanGuo
{
public partial class SanGuo : Form
{
public SanGuo()
{
InitializeComponent();
} private void SanGuo_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://s1.sanguo.yeeyoo.com");
} private void button1_Click(object sender, EventArgs e)
{ if (this.webBrowser1.Url.AbsoluteUri == "http://sanguo.yeeyoo.com/")
{
webBrowser1.Document.GetElementById("identity").InnerText = "yemaoziluo"; //txtuser.Text.ToString().Trim();//fill name webBrowser1.Document.GetElementById("pwd").InnerText = "123123"; //txtpwd.Text.ToString().Trim();//fill pwd foreach (HtmlElement i in webBrowser1.Document.Images)
{
i.GetAttribute("src").ToLower().EndsWith("yysg_13.gif");
i.InvokeMember("click");
break;
}
}
}
}
}//网页代码
<form action="http://sso.yeeyoo.com/ssoLogin.do" method="post" name="loginform" target="_top" id="loginform" onsubmit="return submit_form();">
<table cellspacing="0" cellpadding="0" width="198" align="center" border="0">
<tbody>
<tr>
<td> </td>
</tr>
<tr>
<td>服务器:三国奇缘</td>
</tr>
<tr>
<td>用户名:
<input id="identity" onclick="clearName(this);" size="16" name="identity" /></td>
</tr>
<tr>
<td>密 码:
<input onkeypress="KeyDown();" id="pwd" type="password" size="17" value="" name="pwd" /></td>
</tr>
<tr>
<td align="middle" height="60"><input type="image" height="43" width="198" src="images/yysg_13.gif" border="0" /></td>
</tr>
<tr>
<td><table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</form>
{
public partial class SanGuo : Form
{
public SanGuo()
{
InitializeComponent();
} private void SanGuo_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://s1.sanguo.yeeyoo.com");
} private void button1_Click(object sender, EventArgs e)
{ if (this.webBrowser1.Url.AbsoluteUri == "http://sanguo.yeeyoo.com/")
{
webBrowser1.Document.GetElementById("identity").InnerText = "yemaoziluo"; //txtuser.Text.ToString().Trim();//fill name webBrowser1.Document.GetElementById("pwd").InnerText = "123123"; //txtpwd.Text.ToString().Trim();//fill pwd foreach (HtmlElement i in webBrowser1.Document.Images)
{
i.GetAttribute("src").ToLower().EndsWith("yysg_13.gif");
i.InvokeMember("click");
break;
}
}
}
}
}//网页代码
<form action="http://sso.yeeyoo.com/ssoLogin.do" method="post" name="loginform" target="_top" id="loginform" onsubmit="return submit_form();">
<table cellspacing="0" cellpadding="0" width="198" align="center" border="0">
<tbody>
<tr>
<td> </td>
</tr>
<tr>
<td>服务器:三国奇缘</td>
</tr>
<tr>
<td>用户名:
<input id="identity" onclick="clearName(this);" size="16" name="identity" /></td>
</tr>
<tr>
<td>密 码:
<input onkeypress="KeyDown();" id="pwd" type="password" size="17" value="" name="pwd" /></td>
</tr>
<tr>
<td align="middle" height="60"><input type="image" height="43" width="198" src="images/yysg_13.gif" border="0" /></td>
</tr>
<tr>
<td><table cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</form>
根据你的实际开发情况,考虑是否可以将Page_load事件修改为
private void SanGuo_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
webBrowser1.Navigate("http://s1.sanguo.yeeyoo.com");
}
}