日期:2014-05-20 浏览次数:20876 次
string url = "http://www.baidu.com"; private void button2_Click(object sender, EventArgs e) { string script = @"<script language='javascript' type='text/javascript'> function openUrl(url){ window.open(url,'测试窗口','width=1366px,height=768px,directories=true,location=false,menubar=false,resizeable=false,scrollbars=yes,toolbar=false '); }</script>";//定义脚本 WebBrowser wb = new WebBrowser(); wb.DocumentText = @"<html> <head>" + script + "</head><body></body></html>";//定义WebBrowser中的DOM文档 wb.DocumentCompleted+=new WebBrowserDocumentCompletedEventHandler(method); } void method(object sender, EventArgs e) { WebBrowser wb = sender as WebBrowser; wb.Document.InvokeScript("openUrl", new object[] { url });//执行脚本函数 }
------解决方案--------------------
事件参数是 object sender, WebBrowserDocumentCompletedEventArgs e
private void method(object sender, WebBrowserDocumentCompletedEventArgs e)