Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

JavaScriptBridge

Inherits: Object

Singleton that connects the engine with the browser's JavaScript context in Web export.

Description

The JavaScriptBridge singleton is implemented only in the Web 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 JavaScriptBridge singleton is enabled. Official export templates also have the JavaScriptBridge singleton enabled. See Compiling for the Web in the documentation for more information.

Tutorials

Methods

JavaScriptObject

create_callback ( Callable callable )

Variant

create_object ( String object, ... ) vararg

void

download_buffer ( PackedByteArray buffer, String name, String mime="application/octet-stream" )

Variant

eval ( String code, bool use_global_execution_context=false )

void

force_fs_sync ( )

JavaScriptObject

get_interface ( String interface )

bool

pwa_needs_update ( ) const

Error

pwa_update ( )


Signals

pwa_update_available ( )

Emitted when an update for this progressive web app has been detected but is waiting to be activated because a previous version is active. See pwa_update to force the update to take place immediately.


Method Descriptions

JavaScriptObject create_callback ( Callable callable )

Creates a reference to a Callable that can be used as a callback by JavaScript. The reference must be kept until the callback happens, or it won't be called at all. See JavaScriptObject for usage.


Variant create_object ( String object, ... ) vararg

Creates a new JavaScript object using the new constructor. The object must a valid property of the JavaScript window. See JavaScriptObject for usage.


void download_buffer ( PackedByteArray buffer,