Click to See Complete Forum and Search --> : Creating Window Objects From init()


Geat
01-28-2003, 05:11 AM
I need to create an object from within the init() method (called after the page loads with onLoad), that belongs to the window object. The code:

init() {

var myMenu = new Menu();

showMenu(window.myMenu);

}

results in the error

"window.myMenu" does not exist.

I need the object to belong to window so that a new page is not invoked. Any ideas people?

Charles
01-28-2003, 05:33 AM
function init() {
var myMenu = new Menu();
}

creates the Menu object as a property of the current call object while

function init() {
myMenu = new Menu();
}

creates the Menu object as a property of the window object. Rid yourself of that 'var'.