Call the front-end page function

Call the front-end page function




Overview

In HarmonyOS Next, the runJavaScript() and runJavaScriptExt() methods allow applications to invoke JavaScript functions on the frontend page. These methods facilitate seamless interaction between the application and the frontend, enabling dynamic updates and responses based on user actions or application logic.



Method Comparison

  • runJavaScript() and runJavaScriptExt() differ in parameter types:

    • runJavaScriptExt() supports not only string but also ArrayBuffer parameters, allowing JavaScript script data to be obtained from files.
    • runJavaScriptExt() can retrieve execution results via AsyncCallback.



Example Usage



Frontend Page Code







 

Leave a Reply

Your email address will not be published. Required fields are marked *