【问题标题】:Best practice: delivery of a wallpaper banner with OpenX最佳实践:使用 OpenX 交付墙纸横幅
【发布时间】:2010-08-23 10:03:56
【问题描述】:
我正在寻找一种解决方案,通过广告服务器“openx”提供“壁纸”横幅。壁纸由排行榜横幅(728x90 像素)和垂直摩天大楼组成。我在 OpenX 本身中找不到任何选项,所以我想一定有某种肮脏的方法来完成它。
这里有人有经验吗?我正在考虑只提供一个排行榜横幅,然后将一个剪断的 html 附加到横幅上 - 其中包含我的摩天大楼横幅的标记...:-/
greg0ire > 你可以在这个网站上看到一个“壁纸”横幅的例子(你之前可能会遇到一个覆盖横幅,确保你禁用了广告屏蔽扩展):http://www.allocine.fr/ 有时它在 Flash 中,有时它只是在 body 元素上设置的 background-image css 属性。我想实现第二个选项。
谢谢!
【问题讨论】:
标签:
php
openx
banner
advertisement-server
【解决方案1】:
我使用这种方法让壁纸广告通过 openx 工作。
首先,我在网站的内容包装器下方创建了一个 div(使用 wordpress、header.php 文件)。
<div id="adbg" style=" margin: 0pt auto; height: 1000px; width: 100%; position: fixed; cursor:pointer; ">
然后我用 CSS 中的壁纸图像创建了一个 div 块,并将其作为文本横幅添加到 OpenX 中
<div OnClick="location.href='#';" style="background: url('image.jpg') no-repeat scroll center top #026eb4; height: 100%; width: 100%; margin: 0pt auto; cursor:pointer; "></div>
最后,我把 openx 嵌入代码放在我上面粘贴的 ADBG div 中。
这项技术在所有浏览器上都适用于我。
您当然可以在 adbg div 中获取 CSS 并将其存储在您的 CSS 文件中。
【解决方案2】:
目前,我最终这样做了,但我希望看到更好的解决方案:
<div class="openx_<?php echo $_block->getBlockParameter('css_class');?> openx_background hidden">
<?php echo str_replace('INSERT_RANDOM_NUMBER_HERE', rand(0, 9000), $_block->getBlockParameter('html', ESC_RAW));?>
<?php echo javascript_tag()?>
var checkImg = window.setInterval(function(){
if (jQuery('.openx_background img').length)
{
jQuery("body").css('background', 'url("' + jQuery('.openx_background img').attr('src') + '") no-repeat');
window.clearInterval(checkImg);
}
}, 1000);
//give up 3 s later
setTimeout(function(){
if (jQuery('.openx_background img').length == 0)
{
clearInterval(checkImg);
}
}, 3001);
<?php echo end_javascript_tag()?>
</div>
$_block->getBlockParameter('html', ESC_RAW) 包含 openx javascript 调用代码。