...

View Full Version : add property to window object



otnj2ee
08-23-2007, 06:32 PM
I saw a piece of code in a javascript:

window.dhx_globalImgPath = "test1";

alert(window.dhx_globalImgPath );

display: test1


Now I try:

window.newTest = "A New Test";

alert(window.newTest );

The display does not work.

So the question is: Why is the dhx_globalImgPath so special? It must have been defined or declared somewhere. But I did a full application search for the dhx_globalImgPath. I did not find the expected definition or declaration.

In order to make window.newTest = "A New Test"; workable, I must do something. Then what should I do?

Thanks


Scott

eak
08-23-2007, 08:29 PM
Your code works fine in Firefox.

What browser are you using?

Also, just so you know, when you declare a variable it is assigned to the window object automatically.

var test="hi";
alert(test);
alert(window.test);


Eric

otnj2ee
08-23-2007, 09:21 PM
Thanks. --Scott



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum