日期:2014-05-17 浏览次数:21071 次
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var htmlDoc = (IHTMLDocument3)webBrowser1.Document.DomDocument;
HTMLHeadElement head = htmlDoc.getElementsByTagName("head").Cast<HTMLHeadElement>().First();
var script = (IHTMLScriptElement)((IHTMLDocument2)htmlDoc).createElement("script");
script.text = "window.onload=function() { alert('test') }";
head.appendChild((IHTMLDOMNode)script);
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.hao123.com");
}private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var htmlDoc = (IHTMLDocument3)webBrowser1.Document.DomDocument;
HTMLHeadElement head = htmlDoc.getElementsByTagName("head").Cast<HTMLHeadElement>().First();
var script = (IHTMLScriptElement)((IHTMLDocument2)htmlDoc).createElement("script");
script.text = "window.onload=function() { alert('test') }";
head.appendChild((IHTMLDOMNode)script);
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("http://www.hao123.com");
}