2
0

class_javascript.rst 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. Tutorials
  14. ---------
  15. - `#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`
  16. Methods
  17. -------
  18. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Variant<class_Variant>` | :ref:`eval<class_JavaScript_method_eval>` **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)** |
  20. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
  21. Method Descriptions
  22. -------------------
  23. .. _class_JavaScript_method_eval:
  24. - :ref:`Variant<class_Variant>` **eval** **(** :ref:`String<class_String>` code, :ref:`bool<class_bool>` use_global_execution_context=false **)**
  25. Execute the string ``code`` as JavaScript code within the browser window. This is a call to the actual global JavaScript function ``eval()``.
  26. 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.
  27. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  28. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  29. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`