tags:

views:

160

answers:

2

how can i use a variable of one in another in javascript?

+4  A: 

If the two script tags are on the same page, any variable declared outside of the scope of a function is global to the page.

slolife
darn, lost this race.
seth
+2  A: 

Make it global;

script1.js

 var foobar = "O HAI";

script2.js

  alert(foobar);
seth
I assume all the downvotes here are because we didn't say "Don't use global variables"? Or some other reason?
seth