global or static variables

N

news.t-onlline.de

Hi all,

working with framesets (I know I shouldn't), i need to access a global
variable. I defined this variable at the beginning in xxxx.js, which is
included in every html-file and which contains some functions.
But within these functions, which I call upon from frames, this variable
is not recognized.

An alternative is to be able to work with a "static" variable, which
keeps its value.

Can anybody help?

Best Regards,
Henriette van de Haar, Hamburg/Germany
 
J

Jorge

Hi all,

working with framesets (I know I shouldn't), i need to access a global
variable. I defined this variable at the beginning in xxxx.js, which is
included in every html-file and which contains some functions.
But within these functions, which I call upon from frames, this variable
is not recognized.

An alternative is to be able to work with a "static" variable, which
keeps its value.

Can anybody help?

global vars are properties of the window (global) object, e.g.
window.globalVarName. You can access the globals of the main window
from within the frames as top.globalVarName (instead of window.
globalVarName). Also, note that each frame's code behaves as a
separate thread. See:

http://jorgechamorro.com/cljs/059/

HTH,
 
H

Henriette van de Haar

Hi Conrad

Conrad said:
A news server asking a question? Interesting.


Oh, boy, i changed it right away resp. tried to. Don't know how
Thunderbird could do that to me!
If you include xxxx.js in every HTML document, then wouldn't it also be
included in the document in the frame? If that's the case, there's no
reason why the variable shouldn't be accessible. If you want to access a
global variable in the parent document from a script inside a frame, use
parent.varName (for the top document, use top.varName).

That did it! Thank you.

Best Regards,
Henriette




Unless the frame
 
H

Henriette van de Haar

Hi Jorge,


global vars are properties of the window (global) object, e.g.
window.globalVarName. You can access the globals of the main window
from within the frames as top.globalVarName (instead of window.
globalVarName).

Thanks!

Also, note that each frame's code behaves as a

your link does not work somehow. Thanks anyway. top.VarName or
parent.VarName did it.

Best Regards,
Henriette
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top