Can someone give me a piece of JavaScript code with which I can determine if the JavaScript function is loaded in my aspx web page or exists before it is called?
thank
This will check if your function is defined.
if (typeof functionName === 'function') { alert('loaded'); }
Take a look.
You can explicitly verify that this is a function before calling.
if (typeof(functionName) == "function") functionName();
loaded?
loaded
, - onload, , . , ββ , typeof:
onload
typeof
// Check the type of "myRandomFunction" // Note: typeof is the only way you can use undeclared variables without raising an exception if (typeof myRandomFunction === 'function') { myRandomFunction() }