Click to See Complete Forum and Search --> : what does it mean: if (top.frameX.function-name) {do sth.}


kusi
10-26-2003, 12:11 PM
what does it mean: if (top.frameX.function-name) {do sth.}
ps: I am using this in another frame named frameY.

when does such a thing get the 'true' value and evaluated?
is a function actiually an object in javascript?

is it evaluated to true, if and only if that function has at least once been called inside that frame(i.e. frameX)?

Charles
10-26-2003, 12:35 PM
What you have there is a method and not a function and in a booloean context a method evaulates as true if it exists and false if it does not.

kusi
10-26-2003, 12:54 PM
but say I might have added it from another file. and at the time of being called from another frame, it might not been loaded maybe. then will return false. is this intentionally desihned so?

Charles
10-26-2003, 01:12 PM
Without the () operator a function or method is not called and therefore does not return. But as I wrote before, in a booloean context a method is evaluated as false if it does not exist. And yes, it is often a good idea to make sure that a method exists before calling it.