Created
January 31, 2018 05:49
-
-
Save fernandohenriques/d5d2a59ebe741f434cadde1c33ce96d4 to your computer and use it in GitHub Desktop.
Intelligence when show ads - Five times one, one time other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Intelligence when show ads - Five times one, one time other</title> | |
<style type="text/css"> | |
#googleadsheader.ads1{ width:728px; height:90px } | |
#googleadsheader.ads2{ width:970px; height:250px } | |
</style> | |
<script type="text/javascript"> | |
/* Replace 'data-ad-client' and 'data-ad-slo' with your ads data. */ | |
var ad1 = '<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-12345698989" data-ad-slot="10101010101"></ins>'; | |
var ad2 = '<ins class="adsbygoogle" style="display:inline-block;width:970px;height:250px" data-ad-client="ca-pub-1234566999" data-ad-slot="10101010101"></ins>'; | |
function writeAds(ads,fatherid,fatherclass) { | |
var fatherdiv = document.getElementById(fatherid); | |
fatherdiv.setAttribute("class",fatherclass); | |
document.write(ads); | |
} | |
function showads() { | |
if (typeof(Storage) !== "undefined") { | |
if (localStorage.totalads1) { | |
var totalads1 = parseInt(localStorage.getItem("totalads1")); | |
if(totalads1 > 5) { | |
writeAds(ad2,'googleadsheader','ads2'); | |
localStorage.removeItem("totalads1"); | |
} else { | |
writeAds(ad1,'googleadsheader','ads1'); | |
totalads1++; | |
localStorage.setItem("totalads1",totalads1); | |
} | |
} else { | |
writeAds(ad1,'googleadsheader','ads1'); | |
localStorage.setItem("totalads1","1"); | |
} | |
} else writeAds(ad1,'googleadsheader','ads1'); | |
} | |
</script> | |
</head> | |
<body> | |
<!-- Position this block where the ad should appear. --> | |
<div id="googleadsheader" style="margin:0 auto"> | |
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> | |
<script type="text/javascript">showads();</script> | |
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script> | |
</div> | |
</body> | |
</html> | |
<!-- Separate HTML, JS and CSS when using. This is just an example. ;) --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment