判断是否网络正常
p rivate bool IsConnectedToInternet()
{
int Desc;
return internet.InternetGetConnectedState(out Desc, 0);
}
设置默认页面:
webBrowser1.Navigate(new Uri("http://www.ic2ic.com/copy.jsp"));
登录代码:
p rivate void btnlogin_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("id").InnerText =txtuser.Text.ToString().Trim();//fill name
webBrowser1.Document.GetElementById("passwd").InnerText =txtpwd.Text.ToString().Trim();//fill pwd
HtmlElement formLogin = webBrowser1.Document.Forms["frmLogin"];
formLogin.InvokeMember("submit");
Thread.Sleep(5000);
herfclick("http://www.ic2ic.com/upload.jsp");//这是登录成功的操作,跳转到//upload.asp
//注意不是直接跳过去的,模拟点击链接
//SESSION不会丢失
herfclick("http://www.ic2ic.com/copy.jsp");
}
模拟点击链接:
p rivate void herfclick(string url)
{
for (int i = 0; i < webBrowser1.Document.All.Count; i++)
{
if (webBrowser1.Document.All[i].TagName == "A" && webBrowser1.Document.All[i].GetAttribute("href").ToString().Trim() ==url)
{
webBrowser1.Document.All[i].InvokeMember("click");//引发”CLICK”事件
break;
}
}
}
运行网页中的JS函数
p rivate void callJsMethod(string jsfun,string jsParameter)//函数名字,函数参数
{
HtmlDocument doc = webBrowser1.Document;
doc.InvokeScript(jsfun,new object[]...{jsParameter});
}
填充数据:
p rivate void filldate(string txt)
{
HtmlElement frmWord = webBrowser1.Document.Forms["frmWord"];//找到from
HtmlElementCollection txtarea = frmWord.GetElementsByTagName("TEXTAREA");
HtmlElementCollection radio = frmWord.GetElementsByTagName("INPUT");
radio[2].InvokeMember("click");//选择radio控件
txtarea[0].InnerText = txt.ToString();
}
Delphi GDI对象之脱屏位图(Offscreen Bitmaps),也叫内存位图
1067. Sort with Swap(0,*) (25)【贪心】——PAT (Advanced Level) Practise
Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
每一个JavaScript开发者都应该知道的10道面试题
【HDOJ 5407】 CRB and Candies (大犇推导
Wireshark默认不抓取本地包的解决方式
Android LaunchMode案例篇
使用ViewPager实现广告滑动效果
剑指offer面试题26-复杂链表的复制