WebBrower(.NET) 応用テクニック
JavaScriptの関数を実行する
WebBrowserで表示しているページの、JavaScriptの関数を実行します。
<html><head>
<title>test page</title>
<script type="text/javascript">
<!--
function alertdisp(message) {
alert(message);
}
// -->
</script>
</head>
<body>
test
</body></html>
<title>test page</title>
<script type="text/javascript">
<!--
function alertdisp(message) {
alert(message);
}
// -->
</script>
</head>
<body>
test
</body></html>
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim message As String() = New String() {"test"} WebBrowser1.Document.InvokeScript("alertdisp", message) End Sub
- Document.InvokeScriptに、JavaScriptの関数名、引数を指定します。
参考