Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global var

Status
Not open for further replies.

lwfg

Programmer
Feb 9, 2009
52
US
I have a project with 4 COldFusion pages in 4 frames. If in watch of those pages, I have a Javascript counter writing counts to a global var.

1. Are there any other scope besides cookie that can be used?
2. What would happen if more than 1 script writes to the global var at the same time?

3. Is there a way in Javascript to tell the difference between a page refresh by a submit button or automatic refresh by meta tag.

Thanks
 
1. You can use cookies, session, client, database.
2. nothing your global var will just increase or decrease, multiply or divide. It depends on what you are doing to your variable.

3. If the button is clicked pass a variable in the querystring or post. Then do a check for this param.

Ordinary Programmer
 
Hi

lwfg said:
1. Are there any other scope besides cookie that can be used?
Web Storage. Its status is still Editor's Draft, but according to the related Wikipedia article :
DOM storage said:
It is supported by Internet Explorer 8, Mozilla-based browsers (e.g., Firefox 2+, officially from 3.5)[sup][2][/sup], Safari 4, Google Chrome 4, and Opera 10.50.
( DOM storage )
lwfg said:
2. What would happen if more than 1 script writes to the global var at the same time?
Do not care. That will not happen. And even if will happen, you can not really do anything against it.
lwfg said:
3. Is there a way in Javascript to tell the difference between a page refresh by a submit button or automatic refresh by meta tag.
Only if you add some distinctive search or anchor to the URL.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top