webBrowser下拉表选项抢焦点问题请教
--------------------编程问答--------------------看不出问题 楼主问题找到没 --------------------编程问答-------------------- 调试下看看 --------------------编程问答--------------------
问题就是图片中说的,当我点击验证码文本框时,焦点马上又跑到日期那里了,根本没法输入验证吗。 --------------------编程问答-------------------- 看看 是不是触发是什么
比如
1.掩码狂的获取脚尖事件 然后你在里面写什么了
2.js之类的 在加载的时候给验证码狂绑定什么函数了
--------------------编程问答-------------------- 感觉你肯定触发什么了 在点验证码狂的时候 --------------------编程问答-------------------- 可以输入啊,而且根本不需要定位焦点啊。
if (WB1.Document.GetElementById("password") != null)
{
WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");
// WB1.Document.GetElementById("nick").Focus();
WB1.Document.GetElementById("password").SetAttribute("value", "xxxxxxxxxx");
// WB1.Document.GetElementById("password").Focus();
WB1.Document.GetElementById("password_again").SetAttribute("value", "xxxxxxxxxxx");
// WB1.Document.GetElementById("password_again").Focus();
this.WB1.Document.GetElementById("year_11").InvokeMember("Click");
this.WB1.Document.GetElementById("month_5").InvokeMember("Click");
this.WB1.Document.GetElementById("day_6").InvokeMember("Click");
if (WB1.Document.GetElementById("code") != null)
{
// WB1.Document.GetElementById("code").Focus();
WB1.Document.GetElementById("code").SetAttribute("value", "aaaaaaaaaaaaa");
}
} --------------------编程问答--------------------
不处理焦点你确定能注册成功??
这一句:webQQReq.Document.GetElementById("nick").Focus();
注释了的话,点击注册时会提示【昵称不能为空】
而且无法在webbrowser控件中的文本框输入验证码,只能通过winform上控件的文本框赋值。
通过抓包发现了,“抢焦点”是激发了某个事件导致不断地向服务器请求数据:
--------------------编程问答-------------------- 你提的问题是抢焦点无法输入验证码,我给的代码已经可以输入验证码了,只是还无法完成注册的问题;
不过你已经找到部分原因了,昵称和密码那里要setfocus()才不会提示为空;
最重要的是年月日那里会不断的跳,我想原因是它可能要判断 是否闰年、某月多少天之类的逻辑,当然也要用setfocus,但是不能连续点击,要给它一定的响应时间,加上Application.DoEvents();就可以了。
if (WB1.Document.GetElementById("password") != null)
{
WB1.Document.GetElementById("nick").SetAttribute("value", "aaabbbccc");
WB1.Document.GetElementById("nick").Focus();
WB1.Document.GetElementById("password").SetAttribute("value", "xxx123");
WB1.Document.GetElementById("password").Focus();
WB1.Document.GetElementById("password_again").SetAttribute("value", "xxx123");
WB1.Document.GetElementById("password_again").Focus();
this.WB1.Document.GetElementById("year_11").InvokeMember("Click");
this.WB1.Document.GetElementById("year_11").Focus();
Application.DoEvents();
this.WB1.Document.GetElementById("month_5").InvokeMember("Click");
this.WB1.Document.GetElementById("month_5").Focus();
Application.DoEvents();
this.WB1.Document.GetElementById("day_6").InvokeMember("Click");
this.WB1.Document.GetElementById("day_6").Focus();
Application.DoEvents();
if (WB1.Document.GetElementById("code") != null)
{
WB1.Document.GetElementById("code").Focus();
WB1.Document.GetElementById("code").SetAttribute("value", txtcode.Text);
}
}
WB1.Document.GetElementById("submit").InvokeMember("Click");
上面的代码经过亲测,一次通过注册,直接就调到输入手机号那里了! --------------------编程问答--------------------
可以输入验证码了,但还是会抢焦点。 --------------------编程问答-------------------- 把你的代码贴出来,你先试试点击2次可以注册不,如果可以应当还是响应的问题;我这里测试是OK的
补充:.NET技术 , C#