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

christof.hoeke at e-7.com christof.hoeke at e-7.com
Fri Nov 28 02:40:01 CST 2003


hi all,
i found a solution myself, sorry for the post...

	var x //seems to put x in the current "namespace" without overwriting the current value
	if (x == undefined)
		//do something other, maybe calling function y but not x
	else 
		//do something with x, e.g. call it

chris


-----Ursprüngliche Nachricht-----
Von: Höke, Christof 
Gesendet: Donnerstag, 27. November 2003 15:01
An: thelist at lists.evolt.org
Betreff: [thelist] javascript detecting if function/var is already
defined


hi,
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
	else 
		//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 
chris
-- 
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 


More information about the thelist mailing list