简体   繁体   English

在模态上显示 Google AdSense 广告

[英]Show Google AdSense ad on modal

I have a banner AdSense ad on my site.我的网站上有一个横幅 AdSense 广告。 It's kicked off by the code snippet they give me.它是由他们给我的代码片段开始的。

In another part of my app, I pop up a modal with some info in it.在我的应用程序的另一部分,我弹出一个包含一些信息的模式。 I'd like to display another ad unit in that modal.我想在该模式中显示另一个广告单元。 I have the following defined in that modal:我在该模式中定义了以下内容:

<script type="text/javascript"><!--
google_ad_slot = "xxxxx";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Nothing happens.什么都没发生。 It's weird to me that you have to include that "show_ads.js" file again.我很奇怪您必须再次包含“show_ads.js”文件。 Also, seems like it would overwrite the global js variables that are on the home page that this modal is on top of.此外,似乎它会覆盖此模式位于主页上的全局 js 变量。

Any ideas how to make this work?任何想法如何使这项工作?

What's probably happening is that your modal container element doesn't exist at the time the page was loaded.可能发生的情况是页面加载时您的模态容器元素不存在。 AdSense is loaded for other ads on your page, and you cannot reload them later. AdSense 会为您网页上的其他广告加载,您以后无法重新加载它们。

A common solution is to load an iframe in your model with an ad in the frame.一个常见的解决方案是在您的模型中加载一个 iframe,框架中包含一个广告。 Unfortunately, this violates the terms of service.不幸的是,这违反了服务条款。 It is also against the terms of service to load an ad in a div that is hidden (as this throws off the click-through ratio).在隐藏的 div 中加载广告也违反服务条款(因为这会影响点击率)。

I think your best option is to place the ad in a div that is normally visible, and then position that div on your modal when needed.我认为您最好的选择是将广告放置在通常可见的 div 中,然后在需要时将该 div 放置在您的模态上。 Not ideal, but the only method I can think of that will keep Google happy.不理想,但我能想到的唯一方法是让谷歌高兴。

We tried Brad's solution and other solutions, non worked, simply reloading the ad after 0.1 seconds of showing the Ad worked for us.我们试图布拉德的解决方案和其他解决方案,不工作,0.1秒钟时间,显示广告为我们工作的根本后重装的广告。

PS: just make sure that you don't use a deprecated reload ad function. PS:请确保您不使用已弃用的重新加载广告功能。

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

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