今天带来的这个效果是我最新整理出来的 仅供新手学习 老鸟略过!!
首先看下要实现的广告效果: ↓↓↓↓↓
两个翻牌广告 和中间的 图片切换广告
按正常制作 这里是JS的广告代码 制作的时候 就要想到如何与科讯的广告系统整合
需准备的东西有:翻牌JS广告代码、图片切换JS代码 、广告图片
下面开始整合
整合方法:科讯广告系统+SQL标签
操作:
1 在科讯的广告系统建立好相应的广告
2 将JS广告代码修改成标签
默认JS广告源代码:
<div id="TurnAD256">
<SCRIPT language=javascript>
function showTurnAD256(basenum){
var leftpic="";
var leftlink="";
leftpic+='http://service.0372.cn/Upimg/20117239432765346.jpg';
leftlink+='http://qf520.cccpan.com/';
leftpic+='|'http://service.0372.cn/Upimg/20117239432765346.jpg';
leftlink+='|http://qf520.cccpan.com/';
leftpic+='|'http://service.0372.cn/Upimg/20117239432765346.jpg';
leftlink+='|http://qf520.cccpan.com/';
var sohuFlash2 = new sohuFlash("/ad/179-103.swf", "TurnAD256", 179, 103, "1");
sohuFlash2.addParam("quality", "high");
sohuFlash2.addParam("wmode", "opaque");
sohuFlash2.addVariable("pics",leftpic);
sohuFlash2.addVariable("links",escape(leftlink));
sohuFlash2.addVariable("stop_time",5000);
sohuFlash2.write("TurnAD256");
}
showTurnAD256(1);
</SCRIPT>
</div>
红色部分是SQL标签需要调用的地方
转换成SQL标签
查询语句:
select gif_url,place,sitename,url,AdOrderID from KS_Advertise where place=62
“62为你广告的ID”
循环体:
<SCRIPT language=javascript>
function showTurnAD256(basenum){
var leftpic="";
var leftlink="";
[loop=1]
leftpic+='{$Field(gif_url,Text,0,...,0,)}';
leftlink+='{$Field(url,Text,0,...,0,)}';
[/loop]
[loop=1]
leftpic+='|{$Field(gif_url,Text,0,...,0,)}';
leftlink+='|{$Field(url,Text,0,...,0,)}';
[/loop]
[loop=1]
leftpic+='|{$Field(gif_url,Text,0,...,0,)}';
leftlink+='|{$Field(url,Text,0,...,0,)}';
[/loop]
var sohuFlash2 = new sohuFlash("/ad/179-103.swf", "TurnAD256", 179, 103, "1");
sohuFlash2.addParam("quality", "high");
sohuFlash2.addParam("wmode", "opaque");
sohuFlash2.addVariable("pics",leftpic);
sohuFlash2.addVariable("links",escape(leftlink));
sohuFlash2.addVariable("stop_time",5000);
sohuFlash2.write("TurnAD256");
}
showTurnAD256(1);
</SCRIPT>
看背景是绿色的地方
因为循环体 3个内容 不是一样的 所以写的时候要一个一个调用 [loop=1][/loop]
这样我们只需要调用SQL标签 就可以实现翻牌广告的JS代码了
翻牌广告需要一个SWF文件和一个JS文件 稍后打包发给大家
需要调用的代码:
<SCRIPT src="/ad/sohuflash_1.js" type="text/javascript"></SCRIPT>
<SCRIPT type=text/javascript>
//右侧翻转标签
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i<tabList.length; i++)
{
if (i == Num)
{
thisObj.className = "active";
document.getElementById(tabObj+"_Content"+i).style.display = "block";
}else{
tabList.className = "normal";
document.getElementById(tabObj+"_Content"+i).style.display = "none";
}
}
}
</SCRIPT>
接下来是图片切换广告
默认JS广告源代码:
<script type="text/javascript">
imgUrl1="/UploadFiles/lunfan/img02.jpg";
imgtext1="轮番广告2;"
imgLink1=escape("http://qf520.cccpan.com/");
imgUrl2="/UploadFiles/lunfan/img03.jpg";
imgtext2="轮番广告3;"
imgLink2=escape("http://qf520.cccpan.com/");
imgUrl3="/UploadFiles/lunfan/img04.jpg";
imgtext3="轮番广告4;"
imgLink3=escape("http://qf520.cccpan.com/");
imgUrl4="/UploadFiles/lunfan/img01.jpg";
imgtext4="轮番广告1;"
imgLink4=escape("http://qf520.cccpan.com/");
var focus_width=590
var focus_height=100
var text_height=0
var swf_height = focus_height+text_height
var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4
var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4
var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4
var flashCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/hotdeploy/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">';
flashCode = flashCode + '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="/ad/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">';
flashCode = flashCode + '<param name="menu" value="false"><param name=wmode value="opaque">';
flashCode = flashCode + '<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">';
flashCode = flashCode + '<embed src="/ad/focus.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"; type="application/x-shockwave-flash" width="'+ focus_width +'" height="'+ swf_height +'" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"></embed>';
flashCode = flashCode + '</object>';
document.write(flashCode)
</script>
红色部分是SQL标签需要调用的地方
转换成SQL标签
查询语句:
select gif_url,place,sitename,url,AdOrderID from KS_Advertise where place=56
“56为你广告的ID”
循环体:
<script type="text/javascript">
[loop=4]
imgUrl{$AutoID}="{$Field(gif_url,Text,0,...,0,)}";
imgtext{$AutoID}="{$Field(sitename,Text,0,...,0,)};"
imgLink{$AutoID}=escape("{$Field(url,Text,0,...,0,)}");
[/loop]
var focus_width=590
var focus_height=100
var text_height=0
var swf_height = focus_height+text_height
var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4
var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4
var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4
var flashCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/hotdeploy/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">';
flashCode = flashCode + '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="/ad/focus.swf"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">';
flashCode = flashCode + '<param name="menu" value="false"><param name=wmode value="opaque">';
flashCode = flashCode + '<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">';
flashCode = flashCode + '<embed src="/ad/focus.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"; type="application/x-shockwave-flash" width="'+ focus_width +'" height="'+ swf_height +'" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"></embed>';
flashCode = flashCode + '</object>';
document.write(flashCode)
</script>
这次写法与上面的有所不同
我们看JS源码:
imgUrl1="/UploadFiles/lunfan/img02.jpg";
imgtext1="轮番广告2;"
imgLink1=escape("http://qf520.cccpan.com/");
imgUrl2="/UploadFiles/lunfan/img03.jpg";
imgtext2="轮番广告3;"
imgLink2=escape("http://qf520.cccpan.com/");
imgUrl3="/UploadFiles/lunfan/img04.jpg";
imgtext3="轮番广告4;"
imgLink3=escape("http://qf520.cccpan.com/");
imgUrl4="/UploadFiles/lunfan/img01.jpg";
imgtext4="轮番广告1;"
imgLink4=escape("http://qf520.cccpan.com/");
循环体:
[loop=4]
imgUrl{$AutoID}="{$Field(gif_url,Text,0,...,0,)}";
imgtext{$AutoID}="{$Field(sitename,Text,0,...,0,)};"
imgLink{$AutoID}=escape("{$Field(url,Text,0,...,0,)}");
[/loop]
{$AutoID} 这个标签我来为大家做下解释:
这个标签是按循环条数而增加的
比如:[loop=4]{$AutoID}[/loop] 这样写
网站前台显示的内容是 1 2 3 4
那么
[loop=?] loop=几 {$AutoID} 就会按数字排序往下排出多少
loop=8 {$AutoID} 显示 1 2 3 4 5 6 7 8
所以这个知识点新手可以记一下
这样我们只需要调用SQL标签 就可以实现图片切换广告的JS代码了
最后谢谢大家的支持!
广告所需JS文件:
以下内容只有回复后才可以浏览,请先登录! 论坛也不知道怎么了 回复也看不了隐藏内容 我只好把所需的JS文件放到隐藏里 其他代码开放了 论坛BUG啊
-----------------------------------------------------------------------------------------