jQuery Mobile + Admob:轮换? [英] jQuery Mobile + Admob: rotation?

查看:45
本文介绍了jQuery Mobile + Admob:轮换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jQuery Mobile Framework 创建了一个移动应用程序.所有页面都在 index.php 中加载(使用 <div data-role="page" id="title">).

在每个页面的页脚中,我添加了 Admob 代码:

<script type="text/javascript">var admob_vars = {pubid: 'XXXXXX',//发布者 IDbgcolor: 'FF9119',//背景颜色(十六进制)text: 'FFFFFF',//字体颜色(十六进制)test: false//测试模式,设置为 false 以接收直播广告};<script type="text/javascript" src="http://mmv.admob.com/static/iphone/iadmob.js"></script>

结果是所有页面都显示相同的广告,这可能是因为所有页面都加载在 index.php 中(因此在 index.php 中,大约同时加载了 10 个广告).

知道如何解决这个问题吗?如何展示不同的广告?每个页面请求的轮转 => 触发了什么 jQuery 函数?

谢谢!

解决方案

您应该删除所有硬编码的调用并执行以下操作:1. 绑定调用以将此代码注入到 'pagebeforeshow' 事件 - 因此每次向用户显示新页面之前,您将获取一个新广告并显示它.2. 如何获取新广告:

另一种选择(我采用了 Admob 文档):您可以通过将广告网页放入 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>...//刷新您想要展示新广告的 IFRAMEvar adIframeEl = document.getElementById("admob_ad");adIframeEl.src = adIframeEl.src;...

`

祝你好运.

I created a mobile application using the jQuery Mobile Framework. All pages are loaded within index.php (using <div data-role="page" id="title">).

In the footer of each page, I added Admob code:

<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).

Any idea how to fix this? How can I show different ads? Adrotation for each page request => what jQuery function is triggered?

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. 2. How to fetch a new Ad:

Another option (I took form Admob doc): You can programmatically display a new ad by putting an ad web page in an 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.

这篇关于jQuery Mobile + Admob:轮换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆