目前我迫切需要关注一种sohu弹窗广告(它们叫做背投广告)的实现方法,为此对其源码做了研究。
目前打开搜狐新闻主页
http://news.sohu.com
就会自动弹出一个背投广告。
这种背投广告的js为如下代码
<script type="text/javascript" src="http://images.sohu.com/bill/s2013/yingliu/test/adm2013_beitoufix.js"></script>
它定义了几个需要用到的函数,比如pop_window等,用来生成一段含有iframe标签的html代码,但是它的调用是在该js文件的外部,也就是html中的尾部附近,如下:
AD = new ADM("BEITOU", 4);
AD.turns=2;AD.src=[];
//AD.src.push("http://images.sohu.com/cs/button/zhilian/2007/fr7604800913.html");
AD.src.push("http://images.sohu.com/bill/s2014/xiaoluanhao/VIP/0312vipbt.html");
AddSchedule(AD);
为了使用ADM对象和AddSchedule函数,你需要在前面再加上一个如下的js脚本
<Script language="Javascript" src="http://images.sohu.com/bill/s2013/PVJS/adm2013-20131114min.js"></Script>
下面我写一个demo来进行测试,代码如下
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>sohu背投广告测试</title>
</head>
<body>
<script src="http://www.sohu.com/sohuflash_1.js" type="text/javascript"></script>
<Script language="Javascript" src="http://images.sohu.com/bill/s2013/PVJS/adm2013-20131114min.js"></Script>
<script type="text/javascript" src="http://images.sohu.com/bill/s2013/yingliu/test/adm2013_beitoufix.js"></script>
<Script language="Javascript">
AD = new ADM("BEITOU", 4);
AD.turns=2;AD.src=[];
AD.src.push("http://images.sohu.com/cs/button/zhilian/2007/fr7604800913.html");
AD.src.push("http://images.sohu.com/bill/s2014/xiaoluanhao/VIP/0312vipbt.html");
AddSchedule(AD);
</script>
</body>
</html>
代码说明如下:
sohuflash_1.js是定义了Cookie对象等,adm2013-20131114min.js定义了ADM对象和AddSchedule函数,adm2013_beitoufix.js专门针对背投广告的效果定义了相关的函数。
真正投放广告的代码在一个单独的js中定义,投放广告的外链是html格式,也就是说,它是一个单独的网页,有iframe结构,和mop的广告是一样的形式,比如下面的代码
<html>
<head>
<script type="text/javascript" src="http://www.sohu.com/sohuflash_1.js"></script>
<title>SOHU AD</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table border=0 width=100% height=100%>
<tr><td align=center>
<div id="bt"></div>
</td></tr>
</table>
<script language="javascript">
<!--
var sohuFlash2 = new sohuFlash("http://images.sohu.com/cs/button/zhilian/2007/7604801012.swf", "POPUNDER", "760", "480", "7");
sohuFlash2.addVariable ("clickthru", "http://doc.go.sohu.com/200702/16767b2d178e00f1deff780e018d067c.php");
sohuFlash2.addParam("quality", "high");
sohuFlash2.addParam("wmode", "opaque");
sohuFlash2.write("bt");
blur();
-->
</script>
</body>
</html>
和下面的
<html>
<head>
<script type="text/javascript" src="http://www.sohu.com/sohuflash_1.js"></script>
<title>SOHU AD</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<table border=0 width=100% height=100%>
<tr><td align=center>
<div id="bt"></div>
</td></tr>
</table>
<script language="javascript">
<!--
var sohuFlash2 = new sohuFlash("http://images.sohu.com/bill/s2014/xiaoluanhao/VIP/7604800312a.swf","_edda072510ef0d57e8117df63f28f594","760","480","7");
sohuFlash2.addParam("quality", "high");
sohuFlash2.addParam("wmode", "opaque");
sohuFlash2.addVariable("clickthru",escape("http://clk.optaim.com/event.ng/Type=click&FlightID=201402&TargetID=sohu&Values=edda0725,10ef0d57,e8117df6,3f28f594&AdID=2724535"));
if(typeof(document.pv)=='undefined') document.pv = new Array();var _a=new Image();var _b=new Image();
_a.src='http://alpha.brand.sogou.com/brand_pv?md5=edda072510ef0d57e8117df63f28f594';document.pv.push(_a);
_b.src='http://imp.optaim.com/201402/edda072510ef0d57e8117df63f28f594.php?a=99';document.pv.push(_b);
sohuFlash2.write("bt");
blur();
-->
</script>
</body>
</html>
这里sohuFlash中的第一个参数是广告内容的外链,_a.src广告详情的外链。这里加了两个广告,是为了每次访问交替播放的效果。
442

被折叠的 条评论
为什么被折叠?



