开发者

AdMob webapp (javascript) - Refresh/ReNew ADS on click event

开发者 https://www.devze.com 2023-02-05 22:27 出处:网络
Hy There I\'v seen alot of admob topics on stackO, but unfortunutaly not for webapp usage. The one script that is presented on the web for using admob from a webpage is always:

Hy There

I'v seen alot of admob topics on stackO, but unfortunutaly not for webapp usage.

The one script that is presented on the web for using admob from a webpage is always:

<script type="text/javascript">
  var admob_vars = 
  {
      pubid: '[id]',
      bgcolor: '000000',
      text: 'ffffff',
      ama: false,
      test: false
   };
  </script> 
  <script type="text/javascript" src="http://mmv.admob.com/static/iphone/iadmob.js"></script> 

Inside my webapp, i have a slideshow with arrows beneath. On click, you go to the next image, and i'm displaying admob ads at the top. Now the problem is, i think i'm always getting the same ad (green one). Is it possible to refresh the DIV that holds my admob script (from above)?

I'm sure there's no need to paste my entire code here, onclick events,..e开发者_开发问答tc. I just wanna know:

a) Does adMob always give the same ad for a particular page? Or does it actually retrieve a diffrent kind of AD when they decide so? b) Can i affect the refresh of the script? I thought of deleting/inserting the script inside my dom w/jquery would be really stupid?

EDIT:

SO I HAVE ADDED an

And then, on the prev(), next() event handlers i attached this:

var adFrame = document.getElementById("admob_ad");
adFrame.src = adFrame.src;

Great, so now i'm refreshing my ads. probably?

a) not always an AD is showing (i think admob does not always send you an ad) b) when an AD is shown, clicking on next() is slower than usual (probably because of the ad fetching) c) have someone tested this ad refreshing for admob webintegration and can someone confirm the ads are counted on their account?

thx


I was able to do this by setting the manual mode var to true for the admob config. Calling the ad initialization code creates an iframe in your target div. You can easily snag a new ad by just setting the iframe's src attribute to it's current src, like:

adFrame = document.getElementById('yourAdIframeId');
adFrame.src=adFrame.src;

Trigger that on your slide change buttons, or setInterval to snag new ads on a timer.

0

精彩评论

暂无评论...
验证码 换一张
取 消