在html中写入内容,并添加js
private void btnTestJs_Click(object sender, EventArgs e) { this.webBrowser1.Navigate("about:blank"); this.webBrowser1.Document.Write("testBody");//make the this.webBrowser1.Document.Body is not null
HtmlElement he = this.webBrowser1.Document.CreateElement("script"); he.SetAttribute("type","text/javascript"); he.SetAttribute("text","alert('test');"); this.webBrowser1.Document.Body.AppendChild(he);//add element }
时间: 2024-11-05 12:28:58