<span id="showAd">An interstitial ad</span>
<script>
var admobid = {}
if (/(android)/i.test(navigator.userAgent)) { // for android & amazon-fireos
admobid = {
banner: '',
interstitial: '',
}
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
admobid = {
banner: '',
interstitial: '',
}
}
function initApp() {
AdMob.createBanner( {
adId: admobid.banner,
isTesting: true,
autoShow: true
} );
AdMob.prepareInterstitial({
adId: admobid.interstitial,
isTesting: true,
autoShow: false,
});
}
if(( /(ipad|iphone|ipod|android|windows phone)/i.test(navigator.userAgent) )) {
document.addEventListener('deviceready', initApp, false);
} else {
initApp();
}
</script>
How I can show an interstitial ad on clicking “showAd”?