SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Aug 28, 2009, 08:07 #1
- Join Date
- Jan 2005
- Location
- ny
- Posts
- 9
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Global variable unrecognized by window.ONLOAD?
I code my global variables first,
then my window.onload function, like this:
Code:var globvar = { oneTimeSwitch: "0", kbinput: document.createElement("INPUT"), kbdivision: document.createElement("DIV"), etc. } window.onload = function() { if (kbinput==undefined) alert("NO KBINPUT!!!!"); setTriggers(); }
"kbinput is not defined"?
Or, I suppose it's the same question,
why doesn't the if statement for undefined element
catch the problem?
-
Aug 28, 2009, 11:01 #2
- Join Date
- Jan 2009
- Location
- Surrey BC, Canada
- Posts
- 309
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Try this:
Code:if (!window.kbinput) alert("NO KBINPUT!!!!");
Bookmarks