Using JavaScript
================
.. note::
JavaScript support is new in version 4.1. Embedded Python support is new in version 4.19. Make sure you are using the latest version of TkinterWeb.
Overview
--------
**Scripting support makes it easy to embed JavaScript or Python code in your document.**
JavaScript is fully supported through Mozilla's SpiderMonkey engine, but not all DOM commands are supported. See the :doc:`api/htmldocument` for an exhaustive list of supported DOM commands.
Setup
------
To enable JavaScript support in TkinterWeb, first install `PythonMonkey
`` element when clicked, you could use the following: .. code-block:: python yourhtmlframe = tkinterweb.HtmlFrame(root, messages_enabled=True, javascript_enabled=True) yourhtmlframe.load_html("""
Hello, world!
Hello, world!
") Using your own interpreter -------------------------- Alternatively, you can register your own callback for ``Test
") You can also use the :attr:`on_element_script` parameter to handle event scripts (i.e. handle an element's ``onclick`` attribute). The element's corresponding Tkhtml node, relevant event, and code to execute will be passed as parameters. If needed you can always then create an :class:`~tkinterweb.dom.HTMLElement` instance from a Tkhtml node: .. code-block:: python from tkinterweb.dom import HTMLElement ... yourhtmlelement = HTMLElement(yourhtmlframe.document, yourtkhtmlnode) ------------------- It is also possible to interact with the document through Python instead. See :doc:`dom`. Please report bugs or request new features on the `issues page