Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to call Javascript method from c# winforms?

I've a JavaScript file and it contains some methods. I want to call those methods from my winform application. Is it possible? If so can you give me a simple example?

I've tried like this

Process.Start("javascript:showuser('User1');return false;");

But it is not recogniging the showuser method. Because my js file is in remote location (ex : http://mysite.com/userprofile.js)

Can you help me to do this

Thank you

like image 356
Nagu Avatar asked Jan 01 '10 10:01

Nagu


1 Answers

You could use a WebBrowser control. Here's a sample post.

webBrowser1.DocumentText = 
    @"<html><head>
      <script type='text/javascript'>
      function testFunction() {
          alert('test');
      }
      </script>
      </head><body></body></html>";
webBrowser1.Document.InvokeScript("testFunction");
like image 81
Darin Dimitrov Avatar answered Oct 13 '22 11:10

Darin Dimitrov