Archive for the ‘Javascript’ Category

Check if a Javascript function exists

1 Comment » by Jon Hibbins on 22 March 2009
Filed under: Code, Javascript, Quick Tips

If you want to check if a Javascript function exists before you attempt to call it and get an error try:

// Check if a Javascript function exists and run it if it does
if(typeof window.Function == 'function') {
    Function();
}