Forum Moderators: open
I have the following script to run on document load.
for(i=0;i<document.getElementsByTagName("iframe").length;i++) if(document.getElementsByTagName("iframe")[i].src.indexOf("domain.tld")>-1){
bug=new Image();
bug.src="/get.php?type=info;
}
I have the get.php page set to not cache using several different PHP headers.
However, on pages where I know there are two iframes with a src that contains domain.tld, I am only seeing one request from the javascript.
I'm wondering if how it is worded, if it just assumes that it is the same file, and just uses the first copy.
Any idea if I'm on target, or what else it might be?
Does anyone know a solution? Thanks.
I found that if I place an alert at the end of the bug, then it would properly loop through.
for(i=0;i<document.getElementsByTagName("iframe").length;i++) if(document.getElementsByTagName("iframe")[i].src.indexOf("domain.tld")>-1){
bug=new Image();
bug.src="/get.php?type=info;
alert(i);
}
Unfortunatly, I really can't have alerts load up on all my pages. I tried other things, like var x=i;, but that didn't seem to work.
var date = new Date();
var bug;
for(var i=0;i<document.getElementsByTagName("iframe").length;i++) if(document.getElementsByTagName("iframe")[i].src.indexOf("domain.tld")>-1){
bug=new Image();
bug.src="/get.php?type=info&junk=" + date.getTime() + i;
}
Having created bug you dont seem to do anything with it, I assume there is some extra code not shown.
[edited by: daveVk at 5:04 am (utc) on Feb. 14, 2007]
Turns out the script was working perfectly. Many hours spent trying to fix something that was working.
The problem was my database that was pulling the information. It was setup so the time the index, so it wasn't allowing two entries with the same time in. That's why the alert worked, because it staggered the time.
Its moments like these that I was I was doing something else.
Essentially, I solved this by using setTimeout to reinitiate the function rapidly for each looping, where "grid" is the name of my table in the HTML document. I would call the function "cycle" with the number of times I wanted the script to loop:
var x=document.getElementById('grid').cells;
function changecolor(whichcell) {
x[whichcell].className='black';
}
function cycle(num) {
newnum = num - 1;
changecolor(newnum);
if (nunum >= 1) {
timer = setTimeout('cycle(nunum)', 5)
}
}