I am a little confused about your question. If you just want to change an element in HTML, Jeremy's answer is the best and easiest way. If you want to invoke a JavaScript document, this should work:
Suppose the webbrowser document contains the following HTML:
<html> <head> <title>Invoke Test</title> </head> <body> <div id="testdiv">Waiting...</div> <script> function changeDate(date) { var x=document.getElementById("testdiv"); x.innerHTML = date; } </script> </body> </html>
To call the javascript JavaScript method for the web browser, you can use something like this:
private void button1_Click(object sender, EventArgs e) { object o = webBrowser1.Document.InvokeScript("changeDate('june')"); }
No need for System.Web, ASP, ScriptManagers or Interop. All the tools needed to manage the objects and events of the web browser and the document have a web browser control.
source share