HTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;//给script标签加js内容element.text = "function sayHello() { alert('hello') }";//将script标签添加到head标签中head.AppendChild(scriptEl);//执行js代码webBrowser1.Document.InvokeScript("sayHello");