1# Invoking Frontend Page Functions on the Application 2 3 4You can call [runJavaScript()](../reference/apis/js-apis-webview.md#runjavascript) on an application to call JavaScript functions of frontend pages. 5 6 7In the following example, when a user clicks the **runJavaScript** button on the application, the **htmlTest()** API of the frontend page will be triggered. 8 9 10- Frontend page code: 11 12 ```html 13 <!-- index.html --> 14 <!DOCTYPE html> 15 <html> 16 <body> 17 <script> 18 function htmlTest() { 19 console.info('JavaScript Hello World! '); 20 } 21 </script> 22 </body> 23 </html> 24 ``` 25 26 27- Application code: 28 29 ```ts 30 // xxx.ets 31 import web_webview from '@ohos.web.webview'; 32 33 @Entry 34 @Component 35 struct WebComponent { 36 webviewController: web_webview.WebviewController = new web_webview.WebviewController(); 37 38 build() { 39 Column() { 40 Web({ src: $rawfile('index.html'), controller: this.webviewController}) 41 Button('runJavaScript') 42 .onClick(() => { 43 this.webviewController.runJavaScript('htmlTest()'); 44 }) 45 } 46 } 47 } 48 ``` 49