SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Feb 10, 2007, 16:05 #1
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Small issue with document.getElementsByTagName
Since I found myself typing out document.getElementsByTagName a lot, I decided to make a Prototype-style function to make it easier:
Code:function $t(e) { return document.getElementsByTagName(e); }
Code:var whatever = $t('body')[0].className;
-
Feb 10, 2007, 16:51 #2
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Are you trying to access html elements before the page has loaded?
Post the simplest example that you can come up with that demonstrates your problem.
-
Feb 10, 2007, 20:19 #3
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I'm a tool. I was trying out thickbox, which uses a JS library called jQuery, and my own $ function (not the one I posted above) was conflicting with the one in jQuery:
Code:function $(e) { return document.getElementById(e); }
-
Feb 10, 2007, 20:48 #4
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
IE's weird and wrong reporting of what line number the error is on just served to add to my confusion.
-
Feb 10, 2007, 20:59 #5
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Yes, that's exactly what happened to me too - I kept removing code and it just wouldn't change. Firefox always reports the line number correctly, but IE6's JS error reporting is utter rubbish.
-
Feb 11, 2007, 04:29 #6
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
but IE6's JS error reporting is utter rubbish.
-
Feb 11, 2007, 09:46 #7
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
But it doesn't tell you the filename... it tells you the page the error is on but not which .js file. if you have more than one JS file or some embedded in the head then it can get quite confusing.
Bookmarks