![]() |
|
|
+ Search |
![]()
|
Apr 5th, 2008 20:31
ha mo, Mark Szlazak, Jean-Bernard Valentaten, Guy Perkins,
Only using a workaround I'm afraid.
Simply declare a global variable and inside the function you assign it
the value of the local variable.
HTH
An addendum.
If you want to use the same variable name locally and globally, say
local variable "x" within the scope of some function and global
variable "x", then make a global assignment to the "x" property of
the "window" object: window.x = x;
<html>
<head>
<script>
x = 20;
function local() {
var x = 10;
return x;
}
alert ('Local x: '+local()+'\nGlobal x: '+x);
function localToGlobal() {
var x = 10;
window.x = x;
return x;
}
alert ('Local x: '+localToGlobal()+'\nGlobal x: '+x);
</script>
</head>
<body>
</body>
</html>
Mark
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com