Python in HTAs

gnu valued customer tlviewer at
Mon Oct 18 19:19:52 CEST 2004

"Marcel van den Dungen" <m_vddungen at> wrote in message news:98862c6.0410171325.352a5df4 at
> Does anybody know how to use Python as the scripting language for HTML
> applications? I tried the following, but I get a script error ('Object
> expected') on the body element.

(Using Win2k sp3 with IE 6 sp1, 
    Active Python 2.3)

You need to use a version of Python with a registered
script engine supporting Active Scripting (Win32 only).

Save your code with the HTA extension. Be reminded that an
HTA is hosted by mshta.exe not Internet Explorer.

To run your code here, I made one small correction
below. I edit with UltraEdit32. After making the change
I pressed the "Run in Default Browser" switch
and it worked.

> <html>
> <head>
> <title>Python controlled HTML application</title>
> <hta:application id="oApplication">
> <script language="python">
> def Onload():
>     alert('hello from python')
>     document.all["idspan"] = 'hello from python'

 document.getElementById('idspan').innerHTML = 'hello from python'

> </script>
> </head>
> <body onload="Onload();">
> <span id="idspan" ></span>
> </body>
> </html>
> Could not find any example on Google either.
> TIA,
> Marcel

More information about the Python-list mailing list