Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > global or static variables

Reply
Thread Tools

global or static variables

 
 
news.t-onlline.de
Guest
Posts: n/a
 
      06-12-2009
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
 
Reply With Quote
 
 
 
 
Jorge
Guest
Posts: n/a
 
      06-12-2009
On Jun 12, 5:08*pm, "news.t-onlline.de" <(E-Mail Removed)> wrote:
> 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,
--
Jorge.
 
Reply With Quote
 
 
 
 
Henriette van de Haar
Guest
Posts: n/a
 
      06-12-2009
Hi Conrad

Conrad Lender schrieb:
> On 12/06/09 17:08, news.t-onlline.de wrote:
>> Hi all,

>
> 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!

>
>> 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.

>
> 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
> points to a document on a different domain - then you're out of luck.
>
>> An alternative is to be able to work with a "static" variable, which
>> keeps its value.

>
> No such thing, but the parent document can keep its state while the
> frame documents change.
>
>
> - Conrad

 
Reply With Quote
 
Henriette van de Haar
Guest
Posts: n/a
 
      06-12-2009
Hi Jorge,



Jorge schrieb:
> On Jun 12, 5:08 pm, "news.t-onlline.de" <(E-Mail Removed)> wrote:
>> 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).


Thanks!

Also, note that each frame's code behaves as a
> separate thread. See:
>
> http://jorgechamorro.com/cljs/059/


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

Best Regards,
Henriette


>
> HTH,
> --
> Jorge.

 
Reply With Quote
 
Jorge
Guest
Posts: n/a
 
      06-12-2009
On Jun 12, 5:47*pm, Henriette van de Haar <(E-Mail Removed)>
wrote:
> (...)
> your link does not work somehow. (...)


Not in IE...

--
Jorge.
 
Reply With Quote
 
Henriette van de Haar
Guest
Posts: n/a
 
      06-13-2009
Jorge schrieb:
> On Jun 12, 5:47 pm, Henriette van de Haar <(E-Mail Removed)>
> wrote:
>> (...)
>> your link does not work somehow. (...)

>
> Not in IE...


True. Firefox has no problems

Best Regards,
Henriette


>
> --
> Jorge.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
global static vs global?? Mark C++ 2 10-16-2007 07:54 AM
Initialize global variable before any other global variables jubelbrus C++ 5 07-20-2007 06:38 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
Global variables on par with ASP's global.asa Wayne ASP .Net 2 11-11-2003 10:58 PM



Advertisments