I am checking if a variable is defined or not. It is working right in Firefox and when it comes to Chrome it is not working:
if(window[myClass] == undefined)
{
return;
}
If the variable is not defined it should return.
I am using window[myClass] because I am taking name of the id from onclick event and using same named variable as id if variable is defined then else part should or if not defined then if part should work.
From the last sentence in your question, sounds like
myClassis actually ID of some element in your document.In such case you should use such code to check if such element really exists:
This will cancel the function when element with such ID does not exist.