Skip to content

Commit

Permalink
Added iframe load event for detecting ad load
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayk7 authored Nov 27, 2019
1 parent b2fac88 commit 5d03e9e
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<div class="indus_full" id="indus_full">
<ul id="all_news" class="top_news_section top-buffer">

<li id="top_news_ads1">
<li id="top_news_ads1" style="display:none;">
<div id="div-gpt-ad-1551357349271-9">
<script type="text/javascript">
googletag.cmd.push(function() {
Expand All @@ -97,16 +97,35 @@
</script>
</li>

<li id="top_news_ads2">
<li id="top_news_ads2" style="display:none;">
<div id="div-gpt-ad-1565767605361-0">
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.pubads().display("/42115163/IP_start.indusos.com_300X250_Mobile", [300,250],"div-gpt-ad-1565767605361-0");
});
</script>
<script type="text/javascript">
googletag.cmd.push(function() {
googletag.pubads().display("/42115163/IP_start.indusos.com_300X250_Mobile", [300,250],"div-gpt-ad-1565767605361-0");
});
</script>
</div>
</li>

<script>
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
switch(event.slot.getAdUnitPath()){
case '/42115163/IP_start.indusos.com_320X100_Mobile':
console.log('Ad 1 HTML loaded@ '+ (Date.now()-timerStart) + ' ms ');
document.querySelector('#div-gpt-ad-1551357349271-9 div iframe').onload = function(){
document.getElementById('top_news_ads1').style.display = 'list-item';
console.log('Ad 1 Content loaded@ '+ (Date.now()-timerStart) + ' ms ');
}
break;
case '/42115163/IP_start.indusos.com_300X250_Mobile':
console.log('Ad 2 HTML loaded@ '+ (Date.now()-timerStart) + ' ms ');
document.querySelector('#div-gpt-ad-1565767605361-0 div iframe').onload = function(){
document.getElementById('top_news_ads2').style.display = 'list-item';
console.log('Ad 2 Content loaded@ '+ (Date.now()-timerStart) + ' ms ');
}
break;
}
});
</script>
</ul>
</div>
</div>
Expand Down

0 comments on commit 5d03e9e

Please sign in to comment.