123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- :github_url: hide
- .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
- .. DO NOT EDIT THIS FILE, but the JavaScript.xml source instead.
- .. The source is found in doc/classes or modules/<name>/doc_classes.
- .. _class_JavaScript:
- JavaScript
- ==========
- **Inherits:** :ref:`Object<class_Object>`
- **Category:** Core
- Brief Description
- -----------------
- Singleton that connects the engine with the browser's JavaScript context in HTML5 export.
- Methods
- -------
- +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Variant<class_Variant>` | :ref:`eval<class_JavaScript_method_eval>` **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)** |
- +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
- Description
- -----------
- The JavaScript singleton is implemented only in HTML5 export. It's used to access the browser's JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs.
- Tutorials
- ---------
- - `#calling-javascript-from-script <../getting_started/workflow/export/exporting_for_web.html#calling-javascript-from-script>`_ in :doc:`../getting_started/workflow/export/exporting_for_web`
- Method Descriptions
- -------------------
- .. _class_JavaScript_method_eval:
- - :ref:`Variant<class_Variant>` **eval** **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)**
- Execute the string ``code`` as JavaScript code within the browser window. This is a call to the actual global JavaScript function ``eval()``.
- If ``use_global_execution_context`` is ``true``, 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.
|