Static Variables 
Author Message
 Static Variables

Hi All,

I want to have does JavaScript have any Static Variables.  To my knowledge
there is one in Math Object for PI.  How do i decalare a static variable in
JavaScript.

I am using dhtml for my project which requires login and password.  i want
to make the login and password static so that they are accessible every
where in the page.

Thanx in advance
Ganapathi



Mon, 18 Mar 2002 03:00:00 GMT  
 Static Variables
Hi

Did you try to put them in a hidden frame....
or a cookie/session....

--
Best Regards
 Vidar Petursson
http://www.icysoft.com


No matter where you go there you are
-

Quote:
> Hi All,

> I want to have does JavaScript have any Static Variables.  To my knowledge
> there is one in Math Object for PI.  How do i decalare a static variable
in
> JavaScript.

> I am using dhtml for my project which requires login and password.  i want
> to make the login and password static so that they are accessible every
> where in the page.

> Thanx in advance
> Ganapathi



Mon, 18 Mar 2002 03:00:00 GMT  
 Static Variables

You can attach them to an object - either put it in the constructor, or in
the prototype:

function AnObject()
{
    this.logon = "username";
    this.password = "password";

Quote:
}

- or -

AnObject.prototype.logon = "username";
AnObject.prototype.password = "password";

Mike Whalen
Windows Script Dev


Quote:
> Hi All,

> I want to have does JavaScript have any Static Variables.  To my knowledge
> there is one in Math Object for PI.  How do i decalare a static variable
in
> JavaScript.

> I am using dhtml for my project which requires login and password.  i want
> to make the login and password static so that they are accessible every
> where in the page.

> Thanx in advance
> Ganapathi



Mon, 18 Mar 2002 03:00:00 GMT  
 Static Variables


Quote:

> You can attach them to an object - either put it in the constructor, or in
> the prototype:

Only 50% correct, I'm afraid Mike ;-)

Quote:
> function AnObject()
> {
>     this.logon = "username";
>     this.password = "password";
> }

These are not "static" - they are instance variables. There's no _real_
equivalent to 'static' in JScript, but adding things to the prototype is the
best you can do:

Quote:
> AnObject.prototype.logon = "username";
> AnObject.prototype.password = "password";

This works fine.

Anyway, I wonder... why not just make them global variables?

Peter

--
Peter J. Torr - Microsoft Windows Script Program Manager

Please do not e-mail me with questions - post them to this
newsgroup instead. Thankyou!



Tue, 19 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Static variables in VBS?

2. Static variable?!

3. How to create a static variable?

4. Static Variable?!

5. Passing variables? Static variables?

6. How to set static user variable with VBScript

7. How to implement search on static web pages?

8. compiling ghostscript static?

9. creating static controls

10. Static Pdf OutPut File

11. static time to digital clock

12. How do I open a recordset static?

 

 
Powered by phpBB® Forum Software