Javascript questions

Having some difficulty with javascript, I’m trying to toggle wireframe mode from a link on a web page, but it keeps giving me ‘null’ for the plugin.

Web page script:


var plugin=null;

function toggle()
	plugin = document.getElementById('MyTest');

Web object code:

<object width="160" height="120"
  type="application/x-panda3d" data="MyTest.p3d" auto_start="1" splash_img="splash.jpg">
    <object width="160" height="120"
        <param name="data" value="MyTest.p3d">
        <param name="auto_start" value="1">
        <param name="splash_img" value="splash.jpg">
<br><font face=arial size=1 color=#aaaaaa>Javascript into Python call</font>
<br><a href="javascript:toggle()"><b>Toggle</b></a>

And I have this in the python startup of the p3d file:

        if base.appRunner:
           base.appRunner.main.base = base

Does this seem correct? Do I have to load the plugin with Javascript for this to work or can I just embed the p3d files? I have multiple plugins per page, is this part of my problem?

What does:

the ‘MyTest’ refer to? The name of the p3d file?

Thanks for any help.

MyTest refers to the ‘id’ property of the plugin element (hence getElementById). So in order for that to work, you should add id=“MyTest” to the attributes of the plugin object.