如果 Google Ads 被屏蔽,我如何显示其他内容?
我有一个用 ASP.NET 和 VB.NET 开发的网站,在页面右侧有一个 160 x 600 google 广告的位置。
当它显示在页面上时看起来不错,但我发现当谷歌广告被屏蔽时,就像在我的工作场所一样,页面看起来不完整。没有任何消息显示广告被屏蔽,只是显示空白。
我不想找到解决阻塞的方法,而是想在它被阻塞时在其位置显示一些东西(例如我自己的图形)。
有办法做到这一点吗?
I have a website developed in ASP.NET and VB.NET which has a place for a 160 x 600 google ad on the right hand side of the page.
It looks good when it shows on the page but I have discovered that when the google ad is blocked, like it is at my workplace, the page looks incomplete. There is no message that shows to say the ad is blocked, it just shows blank.
I don't want to find a way around the blocking, rather I would like to dsiplay something in its place (a graphic of my own for instance) if it is blocked.
Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其放在
中,并在其后面放置一个 JavaScript,通过其高度或
document.frames.length 的值来确定
,AdSense 的存在。如果没有检测到,您可以更改 div 的 insideHTML,或者只是document.write()
某些内容。如果有 AdSense,
document.frames.length
将至少为 1。尽可能简单,因为他们不喜欢看到您的网站干扰他们的 iframe,他们可以屏蔽您的 AdSense 帐户。
Put it in a
<div>...</div>
, and right after it place a JavaScript to determine, by its height or by the value ofdocument.frames.length
, the presence of the AdSense. If it was not detected you change the div's innerHTML, or justdocument.write()
something.If there is AdSense,
document.frames.length
will be at least 1.Make it simpliest as possible because they won't like seeing that your site is messing with their iframe, they can block your AdSense account.
从未尝试过,但您可以尝试使用 css 定位和 z-index 将 Google 广告的透明容器粘贴在其他内容之上。
我真的不知道这会有多好,但如果我处于你的立场,我会尝试这样做。
Never tried it, but you could try to use css positioning and z-index to stick a transparent container for the google ads on top of some other content.
I really have no idea how well that would work, but that's what I'd try if I were in your shoes.
您还可以使用 data-ad-status=unfilled 来操作 dom。
这是一篇有关如何使用它的 Google 文章... https://support。 google.com/adsense/answer/10762946?hl=zh-CN
我仅使用 CSS 完成整个操作...我已经优化了布局,以便在隐藏 Google 广告容器 div 时发挥最佳效果。这是我的 CSS 代码片段。
如果您需要查看实例,请访问此网站... https://eatinglove.com/recipes
you can also use data-ad-status=unfilled to manipulate the dom.
Here's a google article on how to use it ... https://support.google.com/adsense/answer/10762946?hl=en
I'm doing the whole thing with just CSS ... I've optimized the layout to work best when i just hide the google ad container div. Here's my CSS code snipet.
Head on over to this site if you need to see a live example ... https://eatinglove.com/recipes