ASP.NET 网站开发中常用到的广告效果代码

时间:2021-05-28

用本贴持续记录一些收集的广告效果。希望给有需求的朋友们一些支持。也希望朋友们把我未记录的广告形式也给予一起回贴。使本贴更加的完善,也让更多的朋友们分享。
1.翻屏效果
翻屏效果
复制代码 代码如下:
<html>
<head></head>
<body>
<div style="HEIGHT:85px">
<script LANGUAGE='JavaScript'>
document.ns = navigator.appName == "Microsoft Internet Explorer";
function showStr(str,textWidth,num)
{
if(!document.ns)
{
document.write(str[0]+'<br>')
}
else
{
var wrt="";
wrt+='<table border=0 cellspacing=0 cellpadding=0>';
wrt+='<tr><td>';
wrt+='<div id="icefable1'+num+'">';
wrt+='<table width='+textWidth+' border=0 cellspacing=0 cellpadding=0>';
for (var i in str)
{
wrt+='<tr><td height=20>'+str[i]+'</td></tr>';
} scroll_num=i;
wrt+='</table>';
wrt+='</div>';
wrt+='<div id="icefable2'+num+'" style="position:absolute;z-index:1;visibility:hidden"></div>';
wrt+='</td></tr>';
wrt+='</table>';
document.write(wrt);
}
}
function init_srolltext(num){countnum=0;eval('stopscroll'+num+'=false;');
eval('icefable1'+num+'.scrollTop=0;');
rotatenum=0;
eval('icefable1'+num+'.style.width=0;');
eval('icefable1'+num+'.style.height=marqueesHeight;');
eval('icefable1'+num+'.style.overflowX="visible";');
eval('icefable1'+num+'.style.overflowY="hidden";');
eval('icefable1'+num+'.noWrap=true;');
eval('icefable1'+num+'.onmouseover=new Function("stopscroll=true");');
eval('icefable1'+num+'.onmouseout=new Function("stopscroll=false");');
eval('preTop'+num+'=0; ');
eval('currentTop'+num+'=0;');eval('stoptime'+num+'=0;');
eval('icefable2'+num+'.innerHTML="";');
eval('icefable2'+num+'.innerHTML+=icefable1'+num+'.innerHTML;');
eval('icefable1'+num+'.innerHTML=icefable2'+num+'.innerHTML+icefable2'+num+'.innerHTML;');
eval('setInterval("scrollUp'+num+'()",40);');
}
function scrollUp1()
{
if(stopscroll1==true) return;
currentTop1+=1;
if(currentTop1==marqueesHeight+1)
{
stoptime1+=1;
currentTop1-=1;
if(stoptime1==scrolllen*marqueesHeight)
{
currentTop1=0;
stoptime1=0;
}
}
else
{
preTop1=icefable11.scrollTop;
icefable11.scrollTop+=1;
if(icefable11.scrollTop==scrolllen*marqueesHeight+1)
{
preTop1=0;
currentTop1=0;
stoptime1=0;
icefable11.scrollTop=0;
}}}
var strArray1=new Array();strArray1[0]='<a href=http://' width='"+MmyeeAdWidth+"' height='"+MmyeeAdHeight+"'></iframe></div>"
//漂浮据页面底部设定框值,为了美观请不要修改次参数
var marginTop = 10
//漂浮据边框的距离
var marginLeft = 5
var navUserAgent = navigator.userAgent
function load()
{
judge();
move();
}
function move() {
judge();
setTimeout("move();",80)
}
function judge(){
if (navUserAgent.indexOf("Firefox") >= 0 || navUserAgent.indexOf("Opera") >= 0) {
if (MmyeeAdShow != "2") {
document.getElementById("adLeftFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - (MmyeeAdHeight) - marginTop + 'px';
}
if (MmyeeAdShow != "1") {
document.getElementById("adRightFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.body.clientHeight > document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight) - (MmyeeAdHeight) - marginTop + 'px';
document.getElementById("adRightFloat").style.left = ((document.body.clientWidth > document.documentElement.clientWidth)?document.body.clientWidth:document.documentElement.clientWidth) - MmyeeAdWidth - marginLeft + 'px';
}
}
else{
if (MmyeeAdShow != "2") {
document.getElementById("adLeftFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - (MmyeeAdHeight) - marginTop + 'px';
}
if (MmyeeAdShow != "1") {
document.getElementById("adRightFloat").style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + ((document.documentElement.clientHeight == 0)?document.body.clientHeight:document.documentElement.clientHeight) - (MmyeeAdHeight) - marginTop + 'px';
document.getElementById("adRightFloat").style.left = ((document.documentElement.clientWidth == 0)?document.body.clientWidth:document.documentElement.clientWidth) - MmyeeAdWidth - marginLeft + 'px';
}
}
if (MmyeeAdShow != "2") {
document.getElementById("adLeftFloat").style.left = marginLeft + 'px';
}
}
if (MmyeeAdShow != "2") {
document.write("<div id=\"adLeftFloat\" style=\"position: absolute;width:" + MmyeeAdWidth + ";\"><table border=0 cellpadding=0 cellspacing=0><tr><td>"+AdLeftContent+"</td></tr></table></div>");
}
if (MmyeeAdShow != "1") {
document.write("<div id=\"adRightFloat\" style=\"position: absolute;width:" + MmyeeAdWidth + ";\"><table border=0 cellpadding=0 cellspacing=0><tr><td>"+AdRightContent+"</td></tr></table></div>");
}
load();
</script>

6.左侧浮动广告
复制代码 代码如下:
<script event="onload" for="window" language="javascript">
init_Ad_Left();//载入页面后,调用函数init_Ad_Left().
</script>
<script language="javascript">
<!--
function init_Ad_Left() {
document.all.AdLeftLayer.style.posTop = -200;
//设置onLoad事件激发以后,广告层相对于固定后的y方向位置
document.all.AdLeftLayer.style.visibility = 'visible'//设置层为可见
MoveLeftLayer('AdLeftLayer');//调用函数MoveLayer()
}
function MoveLeftLayer(layerName)
{
var x = 20;//浮动广告层固定于浏览器的x方向位置
var y = 200;//浮动广告层固定于浏览器的y方向位置
var diff = (document.documentElement.scrollTop + y - document.all.AdLeftLayer.style.posTop)*.90;
var y = document.documentElement.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = y");
eval("document.all." + layerName + ".style.posright = x");//移动广告层
setTimeout("MoveLeftLayer('AdLeftLayer');", 0);//设置20毫秒后再调用函数MoveLayer()
}
//-->
</script>
<div id="AdLeftLayer" style='position: absolute; width: 100px; height: 200px; z-index: 20;visibility: visible; left: 20px; top: 100px'>
加入你要放置的内容
<!--嵌入子页-->
<iframe id="iframyee11" allowtransparency='true' bordercolor='#000000' frameborder="0" height='20' hspace='0' marginheight="0" marginwidth="0" scrolling="no" src='Detail.aspx' width='120'></iframe>
dsfsfqqq qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqqq qqqqqqqq
qqqqq qqqqqqqq qqqqqqqq qqqqqqq
</div>

7.右侧浮动广告
复制代码 代码如下:
<script event="onload" for="window" language="javascript">
init_Ad_Right();//载入页面后,调用函数init_Ad_Right()
</script>
<script language="javascript">
<!--
function init_Ad_Right()
{
document.all.AdRightLayer.style.posTop = -300; //设置onLoad事件激发以后,广告层相对于固定后的y方向位置
document.all.AdRightLayer.style.visibility = 'visible'; //设置层为可见
MoveRightLayer('AdRightLayer'); //调用函数MoveRightLayer()
}
function MoveRightLayer(layerName)
{
var x = 20; //浮动广告层固定于浏览器的x方向位置
var y = 200;//浮动广告层固定于浏览器的y方向位置
var diff = (document.documentElement.scrollTop + y - document.all.AdRightLayer.style.posTop)*.90;
var y = document.documentElement.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = y");
eval("document.all." + layerName + ".style.posright = x");//移动广告层
setTimeout("MoveRightLayer('AdRightLayer');", 0);//设置20毫秒后再调用函数MoveRightLayer()
}
//-->
</script>
<div id="AdRightLayer" style='position: absolute; width: 100px; height: 200px; z-index: 20;visibility: hidden; right: 30px; top: 600px'>
加入你要放置的内容
<!--嵌入子页-->
<iframe id="iframyee2" allowtransparency='true' bordercolor='#000000' frameborder="0" height='20' hspace='0' marginheight="0" marginwidth="0" scrolling="no" src='Detail.aspx' width='120'></iframe>
hhhhhh hhhhhh hh hhhhhh hhhhhh hhhhhh h hhhhhh hhhhhh hhhhhh hhhhhh hh
</div>

8.左右浮动广告
以下各层不变,在event="onload"中同时加载init_Ad_Left()和 init_Ad_Right()方法
左右浮动广告
复制代码 代码如下:
<script event="onload" for="window" language="javascript">
init_Ad_Left();//载入页面后,调用函数init_Ad_Left()
init_Ad_Right();//载入页面后,调用函数init_Ad_Right()
</script>

9.falsh广告轮显
Flash广告轮显Demo
感谢好友位绰提供此广告展现样式
有兴趣的朋友还可以封装成ASP.NET里的自定义控件。这样使用更为方便。

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章