原因: <form action="" method="POST" name="form_login" target='_blank'>
弹出新页面 webbrowser 就不能控制了 很不方便
解决:检测页面完全加载之后执行
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
private void SetAllWebItemSelf(HtmlElementCollection items)
{
try
{
foreach (HtmlElement item in items)
{
if (item.TagName.ToLower().Equals("iframe", StringComparison.OrdinalIgnoreCase)==false)
{
try
{
item.SetAttribute("target", "_self");
}
catch
{ }
}
else
{
try
{
HtmlElementCollection fitems = item.Document.Window.Frames[item.Name].Document.All;
this.SetAllWebItemSelf(fitems);
}
catch
{ }
}
}
}
catch
{
}
}