Jun 17, 2004 #1 davemarsh Technical User Joined Feb 11, 2003 Messages 12 Location IN Code: function xyz(){ var d=new Date(); } .. is it possible to extract the non-global 'd' var from that function somewhere else in my code? (the function can't return any value...)
Code: function xyz(){ var d=new Date(); } .. is it possible to extract the non-global 'd' var from that function somewhere else in my code? (the function can't return any value...)
Jun 17, 2004 #2 Lrnmore Technical User Joined Jun 11, 2003 Messages 743 Location US davemarsh, You can make a variable's scope "global" by leaving off var like: Code: <html> <head> <title></title> <script> function xyz(){ d = new Date(); } xyz(); </script> </head><body> <script> document.write(d); </script> </body></html> HTH Great Javascript Resource: http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/ Upvote 0 Downvote
davemarsh, You can make a variable's scope "global" by leaving off var like: Code: <html> <head> <title></title> <script> function xyz(){ d = new Date(); } xyz(); </script> </head><body> <script> document.write(d); </script> </body></html> HTH Great Javascript Resource: http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/