■ WebBrowser 클래스에서 자바 스크립트 함수를 호출하는 방법을 보여준다.
▶ 예제 코드 (JAVASCRIPT)
1 2 3 4 5 6 7 8 9 10 |
<script> var value = "^_^"; function GetValue() { return value; } </script> |
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
using System.Windows.Forms; /// <summary> /// 웹 브라우저 /// </summary> private WebBrowser webBrowser = new WebBrowser(); ... this.webBrowser.Navigate("http://localhost/test.html"); MessageBox.Show(this.webBrowser.Document.InvokeScript("GetValue").ToString()); |