在C# WebBrowser控件插入JS代码,并执行!亲测可用!

	HtmlElement script = webBrowser.Document.CreateElement("script");
	script.SetAttribute("type", "text/javascript");
	script.SetAttribute("text", "function _func(){alert('OK')}");
	HtmlElement head = webBrowser.Document.Body.AppendChild(script);
	webBrowser.Document.InvokeScript("_func");

附赠一段javascript清除当前站点cookies的代码:

function _cleancookies() {
	var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
	if (keys) {
		for (var i = keys.length; i--;) document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString()
	}
}