JavaScript
Inherits: Object Singleton that connects the engine with the browser’s JavaScript context in HTML5 export.
Description
The JavaScript singleton is implemented only in the HTML5 export. It’s used to access the browser’s JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs. Note: This singleton can be disabled at build-time to improve security. By default, the JavaScript singleton is enabled. Official export templates also have the JavaScript singleton enabled. See Compiling for the Web in the documentation for more information.
Tutorials
calling-javascript-from-script in Exporting for the Web
Methods
Signals
- pwa_update_available ( )
pwa_update to force the update to take place immediately.
Method Descriptions
- JavaScriptObject create_callback ( Object object, String method ) JavaScriptObject for usage.
- Variant create_object ( String object, … ) vararg
newconstructor. Theobjectmust a valid property of the JavaScriptwindow. See JavaScriptObject for usage.
- download_buffer ( PoolByteArray buffer, String name, String mime=”application/octet-stream” )
buffer. The file will have the givennameandmimetype. Note: The browser may override the MIME type provided based on the filename‘s extension. Note: Browsers might block the download if download_buffer is not being called from a user interaction (e.g. button click). Note: Browsers might ask the user for permission or block the download if multiple download requests are made in a quick succession.
- Variant eval ( String code, bool use_global_execution_context=false )
codeas JavaScript code within the browser window. This is a call to the actual global JavaScript functioneval().use_global_execution_contextistrue, the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine’s runtime environment.
- JavaScriptObject get_interface ( String interface )
interfacemust be a valid property of the JavaScriptwindow. The callback must accept a single Array argument, which will contain the JavaScriptarguments. See JavaScriptObject for usage.
- bool pwa_needs_update ( ) const
trueif a new version of the progressive web app is waiting to be activated. Note: Only relevant when exported as a Progressive Web App.
- Error pwa_update ( )
Performs the live update of the progressive web app. Forcing the new version to be installed and the page to be reloaded.
Note: Your application will be reloaded in all browser tabs.
Note: Only relevant when exported as a Progressive Web App and pwa_needs_update returns
true.
