I have a javascript function.
How to check:
if function was called ( in section have this function), then not
You can use a global variable in a custom namespace to store whether the function has been called.
if(!window.mynamespace){
window.mynamespace={};
}
mynamespace.callMeOnlyOnce=function(){
if(mynamespace.alreadyCalled)return;
alert('calling for the first time');
mynamespace.alreadyCalled=true;
};
// alert box comes
mynamespace.callMeOnlyOnce();
// no alert box
mynamespace.callMeOnlyOnce();