Benoni
08-06-2003, 05:55 AM
Hello,
Could anyone please tell me if I am right or wrong, and wether these bits of code are compatiable on most/all java browsers.
In JavaScript:
Using:
var $myvar = "hello";
Creates a variable with a lifetime untill that function ends, and scope of that function only.
Using:
$myvar = "hello";
Creates a variable with a lifetime of the length the page is loaded and a scope of ALL.
It can be retreived on the same page in a different function using alert($myvar); or from another page in a frames page using alert(top.framename.$myvar);
I also noticed that creating my own tag in HTML code can be read/written to using Javascript:
<body id="bodytag" mybodyvar="hello">
alert(bodytag.mybodyvar);
I think this works - Does it work on most/all Java browsers.
I also think just setting such a tag using JavaScript without setting it up in the HTML code alos works - How compatable is that?
Thanks a lot
Benoni
Could anyone please tell me if I am right or wrong, and wether these bits of code are compatiable on most/all java browsers.
In JavaScript:
Using:
var $myvar = "hello";
Creates a variable with a lifetime untill that function ends, and scope of that function only.
Using:
$myvar = "hello";
Creates a variable with a lifetime of the length the page is loaded and a scope of ALL.
It can be retreived on the same page in a different function using alert($myvar); or from another page in a frames page using alert(top.framename.$myvar);
I also noticed that creating my own tag in HTML code can be read/written to using Javascript:
<body id="bodytag" mybodyvar="hello">
alert(bodytag.mybodyvar);
I think this works - Does it work on most/all Java browsers.
I also think just setting such a tag using JavaScript without setting it up in the HTML code alos works - How compatable is that?
Thanks a lot
Benoni