2
0

class_javascript.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the JavaScript.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_JavaScript:
  6. JavaScript
  7. ==========
  8. **Inherits:** :ref:`Object<class_Object>`
  9. Singleton that connects the engine with the browser's JavaScript context in HTML5 export.
  10. Description
  11. -----------
  12. 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.
  13. **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 <https://docs.godotengine.org/en/3.3/development/compiling/compiling_for_web.html>`_ in the documentation for more information.
  14. Tutorials
  15. ---------
  16. - `#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`
  17. Methods
  18. -------
  19. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Variant<class_Variant>` | :ref:`eval<class_JavaScript_method_eval>` **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)** |
  21. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  22. Method Descriptions
  23. -------------------
  24. .. _class_JavaScript_method_eval:
  25. - :ref:`Variant<class_Variant>` **eval** **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)**
  26. Execute the string ``code`` as JavaScript code within the browser window. This is a call to the actual global JavaScript function ``eval()``.
  27. 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.
  28. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  29. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  30. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`