Page 1 of 1

Using Javascript

Posted: 30 Mar 2006, 13:44
by Guest
Can we use javascript in tree menu. For example; i want to set onclick to the link.. :?:

It's possible!

Posted: 30 Mar 2006, 14:42
by Hans
Hi,

sure it's possible. To call a javascript function from a menu-item you first must define the function and then refer to it. As an example you can code and refer to the function 'test()' in your menu-file (e.g. menu_eng.html) as described:

Code: Select all

<script type="text/javascript">
<!--
   function test() { alert("you are in your test function");  }
   ...
   tree = new treemenu('tree',...);
   ...
   tree.add(1,' Call function test', '','javascript:test()', '', '', '');
   ...
   document.write(tree);                                                                                              
//-->
You will have to leave the target empty and write 'javascript:test()' into the url to refer to the function test (see the help TreeMenu -> First steps -> Menu items). You should not explicitely use the event 'onclick', because this event already is used internally to call the routine 'pick()', which ist part of the treemenu.

I hope this helps. Could you please write your operating experience here?

Thanks for using TreeMenu.
Hans

Re: Using Javascript

Posted: 14 Mar 2008, 23:02
by jsorg@sorgs.org
Hans said: "You will have to leave the target empty ..."

Aha, there's the missing bit !

We were struggling to make javascript links work in our TreeMenu implementation. Everything was looking grand, but a few links weren't working. We had improperly put target frames on them. We blanked them out and now they work.

Thanks for posting this.

Jack