I'm trying to do a proof of concept and I'm having difficulty. I've reduced the code to the bare minimum.
I'm expecting 3 alerts indicating the id's of the 3 <p>'s in the html page. I'm getting the same message all 3 times:
"I am 0 test_p1"
"I am 1 test_p1"
"I am 2 test_p1"
Here is the code:
<body>
<p id="test_p1" m="testme">This is some text</p>
<p id="test_p2" m="xxx">This is some text</p>
<p id="test_p3" m="testme">This is some text</p>
<script>
function do_test () {
var i=0;
var e = document.getElementsByTagName("p");
for (i=0; i<e.length; i++) {
alert("I am "+i+" "+e[i].id);
}
}
I think I must have done something stupid. When I moved it to a openly accessible directory of my webspace, it worked.... I think I can fix it from here. Thanks for the help.
Well, the code does work when it's in a normal page, but when I put the page in a <frame>, it breaks. I know frames are frowned upon, but I have to do it this way. Can anyone think of a reason the SAME FILE doesn't work in a frame?