tallalex85
10-05-2007, 07:28 AM
Hello,
I've got a javascript calling a method on a Java applet and on some pages the applet is displayed twice with the same name, I therefore need to check if there's an array of that object so that I can either preform the action on one or both of them. The current code is:
if (document.equation1.length)
{
document.equation1[0].setBackgroundColor('#ffffff');
document.equation1[1].setBackgroundColor('#ffffff');
} else {
document.equation1.setBackgroundColor('#ffffff');
}
(and if(document.equation1.length > 1) also works)
This works beautifully in IE but in firefox it complains about the length method - I assume because when it's not an array, this method doesn't exist.
The exact error is -
Java class webeq3.ViewerControl has no public field or method named "length"
webeq3.ViewerControl is the applets java file which of course has no method called length.
I've also tried a basic isarray function:
function isArray(obj) {
if (obj.constructor.toString().indexOf("Array") == -1)
return false;
else
return true;
}
But IE didn't enjoy that!
Any ideas what I can do?
Thanks
Alex
I've got a javascript calling a method on a Java applet and on some pages the applet is displayed twice with the same name, I therefore need to check if there's an array of that object so that I can either preform the action on one or both of them. The current code is:
if (document.equation1.length)
{
document.equation1[0].setBackgroundColor('#ffffff');
document.equation1[1].setBackgroundColor('#ffffff');
} else {
document.equation1.setBackgroundColor('#ffffff');
}
(and if(document.equation1.length > 1) also works)
This works beautifully in IE but in firefox it complains about the length method - I assume because when it's not an array, this method doesn't exist.
The exact error is -
Java class webeq3.ViewerControl has no public field or method named "length"
webeq3.ViewerControl is the applets java file which of course has no method called length.
I've also tried a basic isarray function:
function isArray(obj) {
if (obj.constructor.toString().indexOf("Array") == -1)
return false;
else
return true;
}
But IE didn't enjoy that!
Any ideas what I can do?
Thanks
Alex