[thelist] javascript detecting if function/var is already defined

christof.hoeke at e-7.com christof.hoeke at e-7.com
Thu Nov 27 08:00:52 CST 2003

i have a problem with a script which depends on a function x() which may be defined or not, depending on the page.
normally i (at least i think it worked) tried to find out if x is available by checking

	if (x == "undefined") 
		//do something other, maybe calling function y but not x
		//do something with x, e.g. call it

this does not work though (although i am quite sure it worked at one time). i always get a browser error "x is not defined"

any suggestions to make this happen?
try/catch will not work as browsers like netscape 4.x need to be working and i think try/catch cannot even catch these errors...

thanks a lot 

More information about the thelist mailing list