Forum Moderators: open

Message Too Old, No Replies

Scope of js Functions

MyFunction is not defined

         

itKiwi

5:56 pm on Apr 25, 2010 (gmt 0)

10+ Year Member



I'm having trouble with a windowing system I'm trying to use. My index file loads a number of js files, including abc.js, which runs a js function called menuWindow.
menuWindow creates a window and loads menu.html, which runs dTree.js to create a tree menu. The menu will be used to create application windows, such as an addressbook, calendar, todo list, etc.
The dTree menu looks as it should, but when I click on AddContactWindow, for example, nothing happens, and Firebug tells me "AddContactWindow is not defined". AddContactWindow is defined in abc.js, and I can create this window directly from the index.html file.
What is going on ? It seems like I have some sort of scope problem.
Thanks.

daveVk

2:01 am on Apr 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Global variables (including functions) are properties of window, hence AddContactWindow() is short for window.AddContactWindow().

So you need to call xyz.AddContactWindow() where xyz is the window containing AddContactWindow.