martin_narg
07-20-2002, 10:16 AM
I'm trying to loop through all divs on a page and check their id for a phrase (ixx). I've used the code below which works fine for IE, but in Netscape 6 the return wasn't what I was expecting! I know for IE I loop through all the document, and in mozilla/netscape 6 I am just dumping the divs into an array to check in this example.
I'd greatly appreciated any help with this. I'm working out the W3C DOM stuff atm so apols if it's a bit of a noobie question.
Many thanks, script below:
<script>
var ie = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
var myArray = (ie) ? document.all : document.getElementsByTagName("div");
for( var i=0; i<myArray.length; i++ ) {
var str = new String(myArray[i].id);
if( str.indexOf('ixx') != -1 )
alert( str )
}
</script>
Martin
I'd greatly appreciated any help with this. I'm working out the W3C DOM stuff atm so apols if it's a bit of a noobie question.
Many thanks, script below:
<script>
var ie = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
var myArray = (ie) ? document.all : document.getElementsByTagName("div");
for( var i=0; i<myArray.length; i++ ) {
var str = new String(myArray[i].id);
if( str.indexOf('ixx') != -1 )
alert( str )
}
</script>
Martin