110,538
社区成员
发帖
与我相关
我的任务
分享
object index = 0;
IHTMLWindow2 htmlWindow = (IHTMLWindow2)(((HTMLDocumentClass)(webBrowser1.Document.DomDocument)).frames.item(ref index));
IHTMLDocument2 htmlDoc = CrossFrameIE.GetDocumentFromWindow(htmlWindow);
//处理链接
foreach (IHTMLElement htmlEl in htmlDoc.links)
{
_href = htmlEl.getAttribute("href", 1).ToString().ToLower();
if (Regex.IsMatch(_href, "downloadfile"))
{
htmlEl.setAttribute("href", "javascript:alert('本机不支持下载,谢谢合作!')", 1);
}
}
//处理文本
foreach (IHTMLElement htmlInputEl in (IHTMLElementCollection)htmlDoc.all.tags("INPUT"))
{
HtmlElement _HtmlEl = htmlInputEl as HtmlElement;
_text = _HtmlEl.GetAttribute("type");
if (_text.Equals("text"))//如果是文本的话
{
//如何进行动态绑定js脚本事件
}
}
//HtmlElement _HtmlEl = htmlInputEl as HtmlElement;
//_text = _HtmlEl.GetAttribute("type");
_text=htmlEl.getAttribute("type", 1)