简体   繁体   English

jQuery 手机 + Admob:轮换?

[英]jQuery Mobile + Admob: rotation?

I created a mobile application using the jQuery Mobile Framework.我使用 jQuery 移动框架创建了一个移动应用程序。 All pages are loaded within index.php (using <div data-role="page" id="title"> ).所有页面都在 index.php 中加载(使用<div data-role="page" id="title"> )。

In the footer of each page, I added Admob code:在每一页的页脚,我添加了 Admob 代码:

<div data-role="footer">
 <script type="text/javascript">
  var admob_vars = {
  pubid: 'XXXXXX', // publisher id
  bgcolor: 'FF9119', // background color (hex)
  text: 'FFFFFF', // font-color (hex)
  test: false // test mode, set to false to receive live ads
   };
 </script>
 <script type="text/javascript" src="http://mmv.admob.com/static/iphone/iadmob.js"></script>
</div>  

The result is that on all pages the same ad is shown, perhaps this is caused by the fact that all pages are loaded within index.php (so in index.php, about 10 ads are loaded at the same time).结果是在所有页面上都显示了相同的广告,这可能是由于所有页面都在 index.php 中加载(因此在 index.php 中,大约同时加载了 10 个广告)。

Any idea how to fix this?知道如何解决这个问题吗? How can I show different ads?如何展示不同的广告? Adrotation for each page request => what jQuery function is triggered?每个页面请求的 Adrotation => 触发了什么 jQuery function?

Thanks!谢谢!

You should remove all the hard coded calls and do something like that: 1. Bind a call to inject this code to 'pagebeforeshow' event - so each time before a new page is being shown to the user you will fetch a new ad and show it.您应该删除所有硬编码调用并执行以下操作: 1. 绑定调用以将此代码注入“pagebeforeshow”事件 - 因此每次在向用户显示新页面之前,您都会获取新广告并显示它。 2. How to fetch a new Ad: 2. 如何获取新广告:

Another option (I took form Admob doc): You can programmatically display a new ad by putting an ad web page in an IFRAME:另一种选择(我采用 Admob 文档):您可以通过将广告 web 页面放入 IFRAME 以编程方式显示新广告:

   ...
   <iframe id="admob_ad" style="position: absolute; width: 320px; height: 48px; left: 0px; top: 0px;" noresize="noresize" frameborder="0" src="http://your_site.com/your_admob_web_page.html">
   </iframe>
   ...
   // refresh the IFRAME where you want to display a new ad
   var adIframeEl = document.getElementById("admob_ad");

   adIframeEl.src = adIframeEl.src;
   ...

` `

Good luck.祝你好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM