JavaScript.xml 1.7 KB

1234567891011121314151617181920212223242526
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="JavaScript" inherits="Object" version="3.3">
  3. <brief_description>
  4. Singleton that connects the engine with the browser's JavaScript context in HTML5 export.
  5. </brief_description>
  6. <description>
  7. 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.
  8. [b]Note:[/b] 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 [url=https://docs.godotengine.org/en/3.3/development/compiling/compiling_for_web.html]Compiling for the Web[/url] in the documentation for more information.
  9. </description>
  10. <tutorials>
  11. <link>https://docs.godotengine.org/en/3.3/getting_started/workflow/export/exporting_for_web.html#calling-javascript-from-script</link>
  12. </tutorials>
  13. <methods>
  14. <method name="eval">
  15. <return type="Variant" />
  16. <argument index="0" name="code" type="String" />
  17. <argument index="1" name="use_global_execution_context" type="bool" default="false" />
  18. <description>
  19. Execute the string [code]code[/code] as JavaScript code within the browser window. This is a call to the actual global JavaScript function [code]eval()[/code].
  20. If [code]use_global_execution_context[/code] is [code]true[/code], 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.
  21. </description>
  22. </method>
  23. </methods>
  24. <constants>
  25. </constants>
  26. </class>