Create Javascript global variable
Yes, as the others have said, you can use var at global scope (outside of all functions) to declare a global variable:
<script>
var yourGlobalVariable;
function foo() {
// ...
}
</script>
// Alternately, you can assign to a property on window:
<script>
function foo() {
window.yourGlobalVariable = ...;
}
</script>