class_javascript.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the JavaScript.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_JavaScript:
  5. JavaScript
  6. ==========
  7. **Inherits:** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Singleton that connects the engine with the browser's JavaScript context in HTML5 export.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`Variant<class_variant>` | :ref:`eval<class_JavaScript_eval>` **(** :ref:`String<class_string>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)** |
  16. +--------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  17. Description
  18. -----------
  19. 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.
  20. Member Function Description
  21. ---------------------------
  22. .. _class_JavaScript_eval:
  23. - :ref:`Variant<class_variant>` **eval** **(** :ref:`String<class_string>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)**
  24. Execute the string ``code`` as JavaScript code within the browser window. This is a call to the actual global JavaScript function ``eval()``.
  25. 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.