public string GetMeta(string name) { var cc = hostBrowser.GetElementsByTagName(true, "META"); mshtml.IHTMLElement el = cc.item(name, 0) as IHTMLElement; return(el.getAttribute("content") as string); }
/// <summary> /// 将选择文本粘帖到主浏览器激活控件上 /// </summary> /// <param name="text"></param> private void DefaultRule(string text) { IHTMLElement active = hostBrowser.GetActiveElement() as mshtml.IHTMLElement; if (active is mshtml.HTMLInputElement) { mshtml.HTMLInputElement input = active as mshtml.HTMLInputElement; input.value = text; } else if (active is mshtml.HTMLTextAreaElement) { mshtml.HTMLTextAreaElement area = active as mshtml.HTMLTextAreaElement; area.innerText = text; } else if (active is mshtml.HTMLBody) { string contentEditable = active.getAttribute("contentEditable", 0) as string; if (!string.IsNullOrEmpty(contentEditable) && contentEditable == "true") { mshtml.HTMLBody body = active as mshtml.HTMLBody; body.innerText = text; return; } IHTMLElement frame = BrowserExtensions.GetFrame(active) as mshtml.IHTMLElement; if (frame != null) { mshtml.HTMLBody body = active as mshtml.HTMLBody; body.innerText = text; } } else { IHTMLElementCollection ec = hostBrowser.GetElementsByTagName(true, "TEXTAREA") as IHTMLElementCollection; if (ec.length > 0) { mshtml.HTMLTextAreaElement area = ec.item(null, 0) as mshtml.HTMLTextAreaElement; area.innerText = text; } else { ec = hostBrowser.GetElementsByTagName(true, "INPUT") as IHTMLElementCollection; mshtml.HTMLInputElement input = ec.item(null, 0) as mshtml.HTMLInputElement; input.value = text; } } }