Synopsis:
I will demonstrate how to show or hide Google Adsense ads in your layouts
1
Add your Google Adsense ad code snippet in your index.html
Tip: Place it right before <body> tag.
2
Copy paste the Javascript code anywhere below jquery script code.
<script type="text/javascript">
function loadAd_menu() {
var w = jQuery(window).width();
var h = jQuery(window).height();
var left = (w/2) - (320/2);
var top = h-80;
$('#ad').css({'top': top+'px', 'left': left+'px'});
}
function loadAd_levels() {
var w = jQuery(window).width();
var left = (w/2) - (320/2);
var top = 60;
$('#ad').css({'top': top+'px', 'left': left+'px'});
}
function hideAd() {
$('#ad').css({'top': '0px','left':'-999px'});
}
</script>
loadAd_menu is placing the ad 320 by 50 pixels on the bottom of the page in middle then loadAd_levels is placing the ad on the top. loadAd_levels will place the ad block on the top of the page. hideAd will hide the ad. Please rename and edit the values at will.
3
Now lets look on how we can trigger these javascript functions from Construct 2.
I hope it helps someone :D
Have a good one,