news:gQgYj.295700$XH2.256735@fe03.news.easynews.co m...
Quote:
>I am so frustrated. I've been working all weekend on what I thought would
>be a simple script. I never find it easy to look at someone else's code,
>but if someone can help with this I would be very grateful. The script is
>...
>
<script type="text/javascript">
var parentwin = external.menuArguments;
var doc = parentwin.document;
var x = doc.getElementsByTagName("table")
alert(x.length + " table things")
var re = /class='class_18'>(\w+)<\/td>/
>
for (iv in x)
{
var tablerows = x[iv].rows
//alert(tablerows.length + " rows") // results in "'tablerows.length'
is
// null or not an object ???????
>
//var tablerows2 = x[iv].getElementsByTagName("tr") // results in
"Object doesn't
// support this
property or method ??????
>
for (triv in tablerows)
{
alert("triv is \""+ triv + "\"; outerHTML:" +
tablerows[triv].outerHTML)
>
var marray = re.exec(tablerows[triv].outerHTML)
//var marray = re.exec("<td align='center'
class='class_18'>Name</td>")
alert("marray is " + marray)
if (marray != null)
{ alert("match[0] " + marray[0])
alert("match[1] " + marray[1])
}
} // end of for (triv in tablerows)
} // end of for (iv in x)
</script>
>
And the HTML I am running it against is ...
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<table cellpadding='0' cellspacing='0' border='0' align='center'>
<tr>
<td align='center' class='class_18'>Name</td>
<td align='center' class='prl5 class_10'| </td>
<td align='center' class='class_19'>4328-5352</td>
</tr>
</table>
</html>
>
1) Why can't I get the length of tablerows after the var tablerows =
x[iv].rows statement? I'm only interested in a one-row table, so I could
save some processing if I could get the length.
>
2) Why doesn't x[iv].getElementsByTagName("tr") work?
>
3) Why do I go through the loop for (triv in tablerows) twice when
there is only one row in the table? AND when I go through the loop the
first time the value of triv is "length" and the value of the outerHTML is
"undefined"?
>
4) Why doesn't the regular expression work when fed the outerHTML but does
when fed the text contained in the HTML?
>
It was a frustrating weekend and I will appreciate any help anyone can
offer. Thanks, Bob
>
Sorry, I forgot to specify that I run the script under IE 6.0.