0
Hello, I’m developing a system and I need Javascript to add the time between the end of the page load and the click on the content of the iframe. I tried to use the code below, var myInterval, but in iframe it is only '1', that is, it does not update with the passing of seconds. After the page loaded by what looks like the team ('&t=' + myInterval + ') gets the static number 1.
if(!window.alreadyIncluded) {
var t = 0;
var time = 0;
var myInterval = setInterval(function() {
++time;
}, 1000);
var divList = document.getElementsByClassName('network');
for (var i = divList.length - 1; i >= 0; i--) {
t++;
var rf = document.referrer;
var lh = window.location.host;
var slot = divList[i].getAttribute('data-ad-s');
var client = divList[i].getAttribute('data-ad-c');
var width = divList[i].offsetWidth;
var height = divList[i].offsetHeight;
divList[i].innerHTML = ('<iframe id="ad_iframe_' + t + '" name="ad_iframe_' + t + '" width="' + width + '" height="' + height + '" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" src="<?php echo $site->getSiteURL(); ?>/page/generate.php?s=' + slot + '&c=' + client + '&lh=' + lh + '&rf=' + rf + '&t=' + myInterval + '"></iframe>');
}
window.alreadyIncluded = true;
}
I’ve tried several ways to make myInterval keep updating every second even after the full page load, but not it remains static at 1, any idea?
Buddy, the loop takes place in here
var myInterval = setInterval(function() {
 ++time;
 }, 1000);
the rest will not repeat itself– Silvio Andorinha
And how could I get myInterval to keep counting?
– Neto Melo
The added value in the loop is the
var time
themyInterval
no value is just a reference, actually I didn’t quite understand what you want to do.. It’s counting, variabletime
is updated every second– Silvio Andorinha
What I want is that when someone click on the content of the iframe, php give get in the amount of seconds that passed between the loading of the JS and the visitor click, understand? When I put ' + time + ' instead of myInterval $_GET[’t'] returns 0. (I’m using die($_GET[’t']) to check this).
– Neto Melo