PDA

View Full Version : Help setting setAttribute path


donalds
07-25-2007, 02:11 PM
Hello All,
I am trying to figure out what the path would be for setting the src attribute from inside a menu. I am able to get it to work from a button but not from inside the menu.

button path is:
parent.main.setSrc('http://www.google.com');

but when I try to use the same path from in the menu it does not work.

My code is:

<canvas width="100%" height="100%">
<include href="extensions/html.lzx"/>
<class name="browser" extends="window" resizable="true" bgcolor="silver">
<simplelayout axis="x"/>
<menubar name="mbar" placement="menubar">
<menu name="file" >File
<menuitem text="Open">
<method event="onclick">
parent.main.setAttribute('src', 'http://www.google.com');
parent.main.setAttribute('visible', true);
</method>
</menuitem>
</menu>
<menu name="presentations">Presentations
<menuitem text="Installing CallAnalyst" />
<menuitem text="Configure CDM" />
<menuitem text="Installing Services" >
<method event="onclick">
parent.main.setAttribute('src', 'http://www.google.com');
this.main.setAttribute('visible', true);
</method>
</menuitem>
</menu>
</menubar>
<button>GO
<method event="onclick">
parent.main.setSrc('http://www.google.com');
parent.main.setAttribute('visible', true);
parent.main.bringToFront();
</method>
</button>
<html name="main" heightoffset="-74" widthoffset="-19" xoffset="7" yoffset="50">
<method event="oninit">
this.bringToFront();
</method>
<method event="oniframe">
Debug.write('oniframe');
</method>
<method event="onsrc" args="s">
Debug.write('onsrc', s);
</method>
<method event="onload">
Debug.write('onload');
</method>
</html>
</class>
<browser width="100%" height="100%"/>
</canvas>

Any help and an explination of how to figure the path would be great!

Donald

Evangelus
07-25-2007, 04:08 PM
Hi Donald

I think you need parent.parent.parent.main.setSrc(), or similar.

You could also try classroot.main.setSrc().

HTH
Phil

donalds
07-26-2007, 07:30 AM
I tried both options with no luck. Any other ideas?

I am attaching a zip file of all my code. If anyone can help me get this working that would be great. The .lzx file to run is html.lzx

Thanks in advance,
Donald

notzippy
07-26-2007, 08:57 AM
Menus are floating lists so the classroot is different then what you would expect. Your path should be
parent (floatinglist)
owner (menu)
classroot (browser)
main (html)

So in total parent.owner.classroot.main.setSrc() should do the trick...

P.s. You should not use <method event=""> as this is deprecated way of handling events, Use <handler name="onevent"> to do this

donalds
07-26-2007, 11:35 AM
Notzippy,
Thanks for your help, that indeed got the page to open. Now I am trying to move the menu and button out of the window and into the base <canvas> and have it open a new window when you click on the navigation or button. Again it's not working... I changed my menu code to this:
<menuitem text="Google" >
<handler name="onclick">
var brow = new browser( canvas );
parent.classroot.main.setAttribute('src', 'http://www.google.com');
parent.classroot.main.setAttribute('visible', true);
</handler>
</menuitem>
and my button code to:
<button>GO
<method event="onclick">
var brow = new browser( canvas );
parent.classroot.main.setSrc('http://www.google.com');
parent.classroot.main.setAttribute('visible', true);
</method>
</button>

Full Code is...
<canvas width="100%" height="100%">
<include href="extensions/html.lzx"/>
<simplelayout axis="y"/>
<menubar name="mbar" placement="menubar">
<menu name="file" >File
<menuitem text="Open">
<handler name="onclick">
parent.owner.classroot.main.setAttribute('src', 'http://www.google.com');
parent.owner.classroot.main.setAttribute('visible' , true);
</handler>
</menuitem>
</menu>
<menu name="presentations">Presentations
<menuitem text="Installing CallAnalyst" />
<menuitem text="Configure CDM" />
<menuitem text="Google" >
<handler name="onclick">
var brow = new browser( canvas );
parent.classroot.main.setAttribute('src', 'http://www.google.com');
parent.classroot.main.setAttribute('visible', true);
</handler>
</menuitem>
</menu>
</menubar>
<button>GO
<method event="onclick">
var brow = new browser( canvas );
parent.classroot.main.setSrc('http://www.google.com');
parent.classroot.main.setAttribute('visible', true);
</method>
</button>
<class name="browser" extends="window" resizable="true" bgcolor="silver" height="80%" width="100%">

<html name="main" heightoffset="-74" widthoffset="-19" xoffset="7" yoffset="50">
<method event="oninit">
this.bringToFront();
</method>
<method event="oniframe">
Debug.write('oniframe');
</method>
<method event="onsrc" args="s">
Debug.write('onsrc', s);
</method>
<method event="onload">
Debug.write('onload');
</method>
</html>
</class>

</canvas>

I am just not able to reason out the logic of the path. Help?

Thanks again,
Donald

notzippy
07-26-2007, 11:53 AM
You made it easier,now you can go from the bottom up.

var brow = new browser( canvas );
brow.main.setAttribute('src', 'http://www.google.com');
// not entirely sure if this is neccesary
brow.main.setAttribute('visible', true);

donalds
07-26-2007, 12:58 PM
No luck... the window opens but no page is displayed. Any ideas?

Thanks,
Donald