...

View Full Version : IE function problem



EFrost
08-26-2007, 04:26 PM
Hey,

I am having some problems getting a function to work in IE, when it works in other browsers.



function toggleC (obj)
{
var cats = obj.parentNode.getElementsByClassName('category');
var effects = [];
for (var i = 0; i < cats.length; i++)
{
if (cats[i].tagName == "DIV" && cats[i].parentNode.id == obj.parentNode.id)
{
if (cats[i].id != obj.id)
{

if (Element.visible(cats[i])) {
effects.push( new Effect.SlideUp(cats[i],{sync: true, duration: 0.5 }) );
}
} else
{
if (!Element.visible(cats[i])) {
effects.push( new Effect.SlideDown(cats[i],{sync: true, duration: 0.4}) );
} else effects.push( new Effect.SlideUp(cats[i],{sync: true, duration: 0.4}) );
}

}
}
new Effect.Parallel(effects, {duration: 0.4});

}


For some reason, the first line of the function is firing a error.
IE is saying that the object that I'm searching for doesn't support the method. Basically the function is called from a icon inside the div ( toggleC(this); ).

Any help is hugely appreciated !

PremiumBlend
08-26-2007, 05:05 PM
I did a simple test in IE and got it to error when the function definition looked like this:


function toggleC (obj)

but was fine when it looked like this:



function toggleC(obj)

The only difference is that space between the toggleC and the first "(".

EFrost
08-26-2007, 07:06 PM
Thanks for the reply, but still getting the same error.
By the first line, I meant "var cats = obj.parentNode.getElementsByClassName('category');" (ignore the function name etc. )

I went as far as to remove everything except these lines,

function toggleC(obj)
{
var cats = obj.parentNode.getElementsByClassName('category');
}
and the same error is still coming up : "Object doesn't support this property or method"

EFrost
08-26-2007, 08:05 PM
I decided to give up on the getElementsByClassName function, and go with something like this :



var cats = obj.parentNode.childNodes;
for (var i = 0; i < cats.length; i++)
{
if (cats[i].className == "category")
{

PremiumBlend
08-26-2007, 08:18 PM
Are you still getting errors or did your changes fix it?

EFrost
08-26-2007, 09:46 PM
The change fixed it, must have been a problem with getElementsByClassName.
Thanks for the input though.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum