在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 }