Reputation: 39638
Is there a way to put a variable in a javascript file so that it increments whenever the file is called (like a static
var in Java)? I want to use it to prevent calling a js file twice. Or, is there another way to do this?
Upvotes: 2
Views: 590
Reputation: 146302
var checkit = window.check_var;
if(checkit === undefined){ //file never entered. the global var was not set.
window.check_var = 1;
}
else {
alert('FILE WAS CALLED ALREADY!');
}
Upvotes: 4