On Jun 11, 2012, at 2:45 AM, nbezzala wrote: > The code I pasted is from prototype.js, and I didn't write the code. > There seems to be an IE8 error, when prototype.js is defining > getElementsByClassName. > I just used magento, with wowslider, and got this error. I'm not sure > where it is coming from. >
If you are getting that error, check to be sure that the element you are calling from is already "extended" in Prototype parlance. This particular error seems to pop up when you try to call a Prototype method on an element that has not had the Prototype methods added to it. In IE, this happens more often because the (small p) prototype inheritance doesn't work consistently. If you get into the habit of wrapping your calling element in $() before you use a Prototype method on it, you will not get this error. If $() is passed an element that is already extended, it short-circuits very quickly, so there isn't a huge penalty. On a standards-compliant browser, if you call $('someDivId').getWidth(); all the other DOM elements on the page will have the full complement of Prototype Element methods available, because extending one extends all of them through the prototype chain. So you could then use document.getElementById('foo').getWidth() (accessing the element without using Prototype) and still get a sane answer. In IE, you won't get that result, you will get the error you quoted, because each element has to be dragged through the extension process separately. Walter > > On Jun 8, 8:53 pm, Jason Westbrook <jwestbr...@gmail.com> wrote: >> Are you wanting to collect all of the child elements of $(element) ? >> >> try using $(element).childElements() >> >> but actually looking at the whole code it looks like you are defining >> getElementsByClassName - there is already functionality in prototype to do >> this >> >> $$(".classname") will return a list of elements with that classname in the >> entire DOM >> >> if you need to select all elements that are children of a certain node >> $("element").select(".classname") will do that >> >> Jason Westbrook | T: 313-799-3770 | jwestbr...@gmail.com >> >> >> >> >> >> >> >> On Fri, Jun 8, 2012 at 12:51 AM, nbezzala <nbezz...@gmail.com> wrote: >>> I am using prototype version 1.7 on IE8. It works fine on Firefox and >>> Opera. >> >>> The error is in this line >>> var nodes = $(element).getElementsByTagName('*'); >> >>> Below is the code around it. >> >>> / >>> *-------------------------------------------------------------------------- >>> */ >> >>> if (!document.getElementsByClassName) document.getElementsByClassName >>> = function(instanceMethods){ >>> function iter(name) { >>> return name.blank() ? null : "[contains(concat(' ', @class, ' '), >>> ' " + name + " ')]"; >>> } >> >>> instanceMethods.getElementsByClassName = >>> Prototype.BrowserFeatures.XPath ? >>> function(element, className) { >>> className = className.toString().strip(); >>> var cond = /\s/.test(className) ? >>> $w(className).map(iter).join('') : iter(className); >>> return cond ? document._getElementsByXPath('.//*' + cond, >>> element) : []; >>> } : function(element, className) { >>> className = className.toString().strip(); >>> var elements = [], classNames = (/\s/.test(className) ? >>> $w(className) : null); >>> if (!classNames && !className) return elements; >> >>> var nodes = $(element).getElementsByTagName('*'); >>> className = ' ' + className + ' '; >> >>> for (var i = 0, child, cn; child = nodes[i]; i++) { >>> if (child.className && (cn = ' ' + child.className + ' ') && >>> (cn.include(className) || >>> (classNames && classNames.all(function(name) { >>> return !name.toString().blank() && cn.include(' ' + name + >>> ' '); >>> })))) >>> elements.push(Element.extend(child)); >>> } >>> return elements; >>> }; >> >>> return function(className, parentElement) { >>> return $(parentElement || >>> document.body).getElementsByClassName(className); >>> }; >>> }(Element.Methods); >> >>> / >>> *-------------------------------------------------------------------------- >>> */ >> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Prototype & script.aculo.us" group. >>> To post to this group, send email to >>> prototype-scriptaculous@googlegroups.com. >>> To unsubscribe from this group, send email to >>> prototype-scriptaculous+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/prototype-scriptaculous?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To post to this group, send email to prototype-scriptaculous@googlegroups.com. > To unsubscribe from this group, send email to > prototype-scriptaculous+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. > -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.