刷新其中包含 Google 广告的 Div
我有一个包含 Google 广告的
。 我的网站主要是 AJAX,不需要刷新浏览器。 这意味着我的广告也不会刷新,这并不理想,因为用户整天盯着一个广告。所以我想要一种方法来刷新页面上的特定
。 我找到了很多解决方案,但它们都不起作用。 例如,使用JQuery的html功能:$("#ads").html("google ad script here");
这设法刷新整个页面,不知道如何。 我还可以向包含 Google 广告的 HTML 页面发出 AJAX 请求,但我猜测它会具有与上述尝试相同的效果。
我不想使用 iFrame。
我还有其他选择吗? 我的豌豆脑子已经想不起来了。 :)
编辑:
这是允许的,因为只有当用户单击链接时我才会启动刷新。
一个典型的例子是 Yahoo Mail - 他们的新 AJAX 邮箱使用相同的方法,当用户单击链接时,就会显示一个新广告。
I have a <div>
that holds a google ad. My website is mostly AJAX and there is no need for a browser refresh. That means my ads will not refresh either, which isn't ideal, a user staring at one ad all day.
So I wanted a way to refresh a particular <div>
on a page. I found many solutions but they didn't work. For example, using JQuery's html function:
$("#ads").html("google ad script here");
This managed to refresh the whole page no idea how. I can also make an AJAX request to a HTML page that contains the Google ad but I am guessing it will have the same effect as the above attempt.
I do not want to use iFrames.
Is there any other option open to me? My pea brain can not think of anymore. :)
EDIT:
It is allowed since I will be initiating the refresh only when a user clicks a link.
A prime example is Yahoo Mail - their new AJAX mailbox uses this same method, when a user clicks a link then a new ad is shown.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
正如其他两个答案所述,不允许自动刷新您的 AdSense 广告。 据我了解,您只想刷新广告以响应用户操作,但仍然不允许,尽管应该这样做!
请记住,您想要更新广告的原因是为了展示新广告。 显示广告称为“印象”。 当您使用代码刷新广告时,您将自动生成广告展示次数。
AdSense 计划政策< /a> 状态(强调我的):
刷新广告违反了产生印象的规则。 话虽如此,我认为任何有理智的人都会同意,在 AJAX 应用程序中刷新广告以响应用户行为(例如响应点击)并不违反精神< /em> 规则。
例如,想象一下重写整个应用程序以停止使用 AJAX。 对于您的用户来说,这显然是更糟糕的体验(速度较慢,每次点击时页面都会闪烁,页面无法在后台动态更新),但从技术角度来看,这并不违反 AdSense 计划政策。
显然,Google 的意思是禁止每五秒自动更换一次广告(创建广告“幻灯片”)。 谷歌还打算禁止通过看似比实际访问量更多的方式让您的网站对广告商更具吸引力。 我确信他们并没有打算阻止您设计高性能 AJAX 网站...但不幸的是,有时规则会产生意想不到的后果。
当然,正如您最初指出的那样,如果您将广告嵌入 iframe 并修改其位置,您仍然可以刷新广告。 (这里介绍如何在 AJAX 应用程序中使用 iframe 来刷新 AdSense。)
您在最初的问题中拒绝了 iframe,也许是因为您知道使用 iframe 会违反 Google 的政策...但如果您坚持违反规则,您可能会这样做我们一路打破他们! ;-)
最终,我认为您会发现以这种方式产生印象并不值得冒险:您“刷新”广告只会发现 Google 只向您展示与以前完全相同的广告。
As both of the other answers state, refreshing your AdSense advertisements automatically isn't allowed. I understand that you only intend to refresh the ad in response to user action, but it still isn't allowed, even though it should be!
Remember, the reason why you want to update the advertisements is so that you can show new ones. Displaying an advertisement is called an "impression." When you use code to refresh the ads, you are automatically generating ad impressions.
AdSense Program Policies state (emphasis mine):
Refreshing your advertisements is a violation of the letter of the rule against generating impressions. With that said, I think any reasonable person would agree that refreshing advertisements in an AJAX app in response to user behavior (e.g. in response to a click) isn't a violation of the spirit of the rule.
For example, imagine rewriting your entire app to stop using AJAX. That's clearly a worse experience for your users (it's slower, the page flashes on every click, the page can't dynamically update in the background), but, by a technicality, it's not a violation of the AdSense Program Policies.
Clearly Google meant to prohibit automatically replacing the advertisements every five seconds (creating a "slideshow" of advertisements). Google also meant to prohibit making your site look more attractive to advertisers by appearing to have more visits than you actually have. I'm sure they didn't intend to prevent you from designing a high-performance AJAX website... but unfortunately sometimes rules have unintended consequences.
Of course, as you originally pointed out, you CAN still refresh your advertisements if you embed them in an iframe and modify its location. (Here's how to use iframes in an AJAX application to refresh AdSense.)
You rejected iframes in your initial question, perhaps because you knew that using iframes would violate Google's policies... but if you insist on breaking the rules, you might as well break them all the way! ;-)
Ultimately, I think you'll find that generating impressions this way isn't worth the risk: you'll "refresh" the ads only to find that Google is just showing you the exact same ads as before.
新的 Google DFP“标签”专门允许“AJAX 广告刷新”
The new Google DFP 'tags' allow specifically 'ad refreshing for AJAX'
我知道我迟到了一年半,但是......广告的问题可能是他们正在使用
document.write
(广告服务器因此而臭名昭著,但我不知道 AdSense 是否使用它。)如果是这样,我有一个可以提供帮助的库:writeCapture.js。 示例:
这是使用 jQuery,但也有一个独立版本。
至于是否违反服务条款... Gmail 会动态更改广告,因此情况不会那么糟糕。 只要内容也在改变,我认为就可以了。
I know I'm a year and a half late to the party, but... It's possible that the problem with the ads is that they are using
document.write
(Ad servers are notorious for this, but I don't know if AdSense uses it or not.)If that's the case, I have a library that can help: writeCapture.js. Example:
That's using jQuery, but there is also a standalone version.
As for whether it's a TOS violation... Gmail changes ads dynamically, so it can't be that bad. As long as the content is changing too, I would think it was OK.
您可以使用以下代码刷新 Google 广告位。 将其放入要刷新广告的 JS 函数中。 它应该刷新页面上的所有广告。
Google Ad Manager 帮助 - 无需刷新页面即可重新加载广告
You can refresh the Google Ad Slots with the following code. Put this in the JS function you want to refresh the Ads. It should refresh all of the ads on the page.
Google Ad Manager Help - Reload ads without a page refresh
只需将广告包含在您通过 ajax 加载的页面中即可。 通过 ajax 按页面从文件加载广告不会有任何问题。
如果我加载有一些内容和广告的 Read.inc
单击页面上的某个内容,您将进入 Make.inc,其中包含内容和广告。
这有什么问题吗? 那是有机的。 将广告作为内容的一部分加载一次。
这与单击链接相同。
我还没有真正尝试过,但这看起来确实合乎逻辑。
Just include the ads in the pages you are loading via ajax. There can be nothing wrong with loading the ads from a file via ajax on a per page basis.
if I load Read.inc which has some content and an ad
Click something on the page and it takes you to Make.inc which has content an an ad.
Whats wrong with that? That's organic. One load with the ad as part of the content.
It's the same as clicking a link.
I haven't actually tried this yet, but it certainly seems logical.
不允许(根据 AdSense 条款)在页面生命周期内尝试重新加载广告。 而且,这几乎不可能(由于平台架构)。
It is not allowed (according to AdSense terms) to try and reload ads during the page life-cycle. Also, it is hardly possible (thanks to the platform architecture).
不允许。 但我认为你可以使用 iframe 来实现这一点。 我看到了很好的教程。
我尝试通过 ajax 回滚我对 Adsense TOS 的更改
It is not allowed. but I think you can use a iframe for that. I saw good tutorials of that.
I tried do it by ajax by I rollback my changes for the Adsense TOS