欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2024-03-08 16:21:00
用本贴持续记录一些收集的广告效果。希望给有需求的朋友们一些支持。也希望朋友们把我未记录的广告形式也给予一起回贴。使本贴更加的完善,也让更多的朋友们分享。 1.翻屏效果 翻屏...
用本贴持续记录一些收集的广告效果。希望给有需求的朋友们一些支持。也希望朋友们把我未记录的广告形式也给予一起回贴。使本贴更加的完善,也让更多的朋友们分享。
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://www.dearbook.com.cn/book/searchbook.aspx?keyword=电脑时尚应用系列 target=_blank><img border=0 src=/image/shishang.jpg height=80 width=150></a> <a href=http://www.dearbook.com.cn/book/searchbook.aspx?keyword=实例精讲 target=_blank><img border=0 src=/image/button20.gif height=80 width=150></a> <a href=http://www.dearbook.com.cn/book/searchbook.aspx?keyword=企业级开发案例精解 target=_blank><img border=0 src=/image/button21.gif height=80 width=150></a> <a href=http://www.dearbook.com.cn/subject/top50/ target=_blank><img border=0 src=/image/button15.gif height=80 width=150></a> ';strarray1[1]='<a href=http://www.dearbook.com.cn/2005/c++/ target=_blank><img border=0 src=/image/primer.jpg height=80 width=150></a> <a href=http://www.dearbook.com.cn/subject/vbzh/ target=_blank><img border=0 src=/image/vb-bt.jpg height=80 width=150></a> <a href=http://www.dearbook.com.cn/book/searchbook.aspx?keyword=开发答疑&searchtype=0&corder=3&page=1&log=0 target=_blank><img border=0 src=/image/hospital.jpg height=80 width=150></a> <a href=http://www.dearbook.com.cn/book/searchbook.aspx?keyword=国外计算机科学教材系列 target=_blank><img border=0 src=/image/wh.jpg height=80 width=150></a> <a href=http://www.dearbook.com.cn/subject/c++/index.htm target=_blank><img border=0 src=/image/c++.jpg height=80 width=150></a> ';var scrolllen=strarray1.length;marqueesheight=82;showstr(strarray1,580,1);init_srolltext(1);</script>
</div>
</body>
</html>

2.广告轮显
轮流显示
复制代码 代码如下:

<html>
<head>
<script>
var elady_tp=new array();
var elady_tplink1=new array();
var elady_tptext=new array();
var adnumvii=0;
elady_tp[0]="http://pic1.e26.cn/mb/5108/yft/images/1.gif"
elady_tp[1]="http://pic1.e26.cn/mb/5108/yft/images/3.gif"
elady_tp[2]="http://pic1.e26.cn/mb/5108/yft/images/2.gif"
var elady_cimage=new array();
for (i=1;i<=5;i++){elady_cimage[i]=new image();
elady_cimage[i].src=elady_tp[i];
}
function set_coelady1(){ if (document.all)
{ elady_tprotator1.filters.revealtrans.transition=math.floor(math.random()*23);
elady_tprotator1.filters.revealtrans.apply(); }
}
function play_coelady1()
{ if (document.all) elady_tprotator1.filters.revealtrans.play()
}function next_elady1(){ if(adnumvii<elady_tp.length-1)adnumvii++ ;
else adnumvii=0;
set_coelady1();
document.images.elady_tprotator1.src=elady_tp[adnumvii];
play_coelady1();
thetimer=settimeout("next_elady1()", 4000);}
function linkurl1(){ jumpurl1=elady_tplink1[adnumvii];
jumptarget1='_blank';
if (jumpurl1 != ''){ if (jumptarget1 != '')window.open(jumpurl1,jumptarget1);
else location.href=jumpurl1;
}}
function listmsg1()
{ status=elady_tplink1[adnumvii];
document.returnvalue = true;
}
</script>
</head>
<body>
<img style="filter: revealtrans(duration=2,transition=20)" src="javascript:next_elady1()" border=0 name=elady_tprotator1 width="188" height="150"></a>
</body>
</html>

3.流动广告
流动广告
复制代码 代码如下:

<html>
<head></head>
<body>
<marquee onmouseover=this.stop() onmouseout=this.start() scrollamount=5 behavior=alternate>
<table cellspacing=0 cellpadding=2 width="100%" border=0>
<tbody>
<tr>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1301.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1306.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1311.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1203.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1208.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1219.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1224.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1234.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1258.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1280.gif" width="150" height="150"></td>
<td><img src="http://pic1.e26.cn/mb/5108/yft/images/gun/1356.gif" width="150" height="150"></td>
</tr>
</tbody>
</table>
</marquee>
</body>
</html>

4.移动广告框
移动广告
复制代码 代码如下:

<div id="img" style="left:27px; visibility=hidden;position:absolute; top:1115px">
<a href="www.eyou.com" target="_blank">
<img border=0 src="uploadad/gg.png" width=400 height=50>
</a>
</div>
<script language="javascript">
<!-- begin
var xpos = 20;
var ypos = document.body.clientheight;
var step = 1;
var delay = 30;
var height = 0;
var hoffset = 0;
var woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img.style.top = ypos;
function changepos() {
width = document.body.clientwidth;
height = document.body.clientheight;
hoffset = img.offsetheight;
woffset = img.offsetwidth;
img.style.left = xpos + document.body.scrollleft;
img.style.top = ypos + document.body.scrolltop;
if (yon) {
ypos = ypos + step;
}
else {
ypos = ypos - step;
}
if (ypos < 0) {
yon = 1;
ypos = 0;
}
if (ypos >= (height - hoffset)) {
yon = 0;
ypos = (height - hoffset);
}
if (xon) {
xpos = xpos + step;
}
else {
xpos = xpos - step;
}
if (xpos < 0) {
xon = 1;
xpos = 0;
}
if (xpos >= (width - woffset)) {
xon = 0;
xpos = (width - woffset);
}
}
function start() {
img.style.visibility = "visible";
interval = setinterval('changepos()', delay);
}
start();
// end -->
</script>

5.左右底部广告
复制代码 代码如下:

<script type="text/javascript" language="javascript">
var mmyeeadshow = 3; //1为左侧显示 2为右侧显示 其他为两侧显示
var mmyeeadwidth =300; //广告宽度
var mmyeeadheight = 200; //广告高度
//左边浮动
var adleftcontent= "<div><iframe id='iframyee' bordercolor='#000000' frameborder='0' hspace='0' marginheight='0' marginwidth='0' scrolling='no' src='http://a311300.cnblogs.com' width='"+mmyeeadwidth+"' height='"+mmyeeadheight+"'></iframe></div>";
//右边浮动
var adrightcontent = "<div><iframe id=iframyee frameborder=0 marginwidth=0 marginheight=0 bordercolor='#000000' hspace='0' scrolling=no src='http://a311300.cnblogs.com' 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里的自定义控件。这样使用更为方便。