网页两边跟随滚动条上下移动的小广告是怎么做的?

63712885 2005-01-13 10:44:11
网页两边跟随滚动条上下移动的小广告是怎么做的?
...全文
1157 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
minizhang 2005-02-02
  • 打赏
  • 举报
回复
<!--跟随开始-->
<script language="javascript">
<!--
function openhrwin() {
window.open ("*.htm", "*****", "height=300, width=300, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no") //写的一个弹出窗口的函数,方便点击广告弹出。(可选)
}
suspendcode="<DIV id=minizhang style='Z-INDEX: 10; right: 10px; POSITION: absolute; TOP: 400px; width: 88px; height: 88px;'><A HREF='#'><IMG SRC='图片' WIDTH='80' HEIGHT='80' BORDER='0' onclick='openhrwin()'></A></DIV>"//跟随广告,左右、大小、形式、事件设置。注意<DIV>的ID
document.write(suspendcode);
lastScrollY=0;
function heartBeat(){//两侧都挂时函数名不能一样
diffY=document.body.scrollTop;
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.all.minizhang.style.pixelTop+=percent;//注意<DIV>的ID
lastScrollY=lastScrollY+percent;
}
window.setInterval("heartBeat()",1);
//-->
</script>
<!--跟随结束-->
heroabi 2005-01-28
  • 打赏
  • 举报
回复
学习...
chinaboson 2005-01-16
  • 打赏
  • 举报
回复
www.ddvip.com
什么样的都有,直接去看好了
beacholi 2005-01-16
  • 打赏
  • 举报
回复
<!--两侧广告 开始端-->
<div id="JBStatic" style="position: absolute; width: 80; height: 80; z-index: 25; left: 850px; top: 120px; background-color: #ffffff; background-repeat: repeat; background-attachment: scroll; layer-background-color: #000000; border: 1px none #000000; background-position: 0% 50%">
<a href="http://www.hiall.com.cn/bbs/User/UserJoin.asp"><font color=red>攒积分<br>换HI币<br></font>立即<font color=blue>注册</font>!</a> </div>
<script language=JavaScript>
function JB_keepItInIE(theName,theWantTop,theWantLeft){
theRealTop=parseInt(document.body.scrollTop)
theTureTop=theWantTop+theRealTop
document.all[theName].style.top=theTureTop
theRealLeft=parseInt(document.body.scrollLeft)
theTureleft=theWantLeft+theRealLeft
document.all[theName].style.left=theTureleft
}
setInterval('JB_keepItInIE("JBStatic",250,890)',1)
//JB是层的id,修改名称时必须将这里面的所有“JB”修改,代码才能运行;(共四个“JB”)
//setInterval('JB_keepItInIE("JBStatic",250,890)',1)是设置层在网页中的位置,250是指相对与网页顶部,890是相对于网页左边;
//此为右侧移动对联广告;
</script>
<div id="LBStatic" style="position: absolute; width: 80; height: 80; z-index: 25; left: 850px; top: 120px; background-color: #ffffff; background-repeat: repeat; background-attachment: scroll; layer-background-color: #000000; border: 1px none #000000; background-position: 0% 50%">
<a href="http://www.hiall.com.cn/bbs/User/UserJoin.asp"><font color=red>攒积分<br>换HI币<br></font>立即<font color=blue>注册</font>!</a> </div>
<script language=JavaScript>
function LB_keepItInIE(theName,theWantTop,theWantLeft){
theRealTop=parseInt(document.body.scrollTop)
theTureTop=theWantTop+theRealTop
document.all[theName].style.top=theTureTop
theRealLeft=parseInt(document.body.scrollLeft)
theTureleft=theWantLeft+theRealLeft
document.all[theName].style.left=theTureleft
}
setInterval('LB_keepItInIE("LBStatic",250,10)',1)
//JB是层的id,修改名称时必须将这里面的所有“JB”修改,代码才能运行;(共四个“JB”)
//setInterval('JB_keepItInIE("JBStatic",250,890)',1)是设置层在网页中的位置,250是指相对与网页顶部,100是相对于网页左边;
//此为左侧移动对联广告;
//在相应的层中加入图片和链接即可;
</script>
<!--两侧广告 结束端-->
purple_x 2005-01-14
  • 打赏
  • 举报
回复
floatleft_close.js 代码
var imgheight_close
var imgleft
window.screen.width>800 ? imgheight_close=550:imgheight_close=300
window.screen.width>800 ? imgleft=2:imgleft=2
function myload()
{
myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight_close;
myleft.style.left=imgleft;
leftmove();
}
function leftmove()
{
myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight_close;
myleft.style.left=imgleft;
setTimeout("leftmove();",50)
}

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true)

function close_float_left(){
myleft.style.visibility='hidden';
}

document.write("<div id=myleft style='position: absolute;width:100;top:50;left:2;visibility: visible;z-index: 1'>"
+"<style>"
+".closefloat{text-decoration:none;color:#000000;font-size:12px}"
+".closefloat:hover{text-decoration:underline;color:#0000FF;font-size:12px}"
+"</style>"
+"<table border=0 cellpadding=0 cellspacing=0><tr><td>");

if(ad_float_left_type!="swf")
document.write("<a href='" + ad_float_left_url + "' target = '_blank'><img src='" + ad_float_left_src + "' WIDTH=100 HEIGHT=300 border = 0></a>");
else
document.write("<EMBED src='" + ad_float_left_src + "' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash' id=changhongout ></EMBED>");

document.write("</td></tr><tr><td width=100 height=20 align=right><a href='javascript:close_float_left();void(0);' class=closefloat>关闭</a></td></tr>"
+"</table>"
+"</div>");

myload()
purple_x 2005-01-14
  • 打赏
  • 举报
回复
浮动广告条代码
<script LANGUAGE='JavaScript'>
var ad_float_right_src = "xxx.gif";
var ad_float_right_url = "xxx.htm";
var ad_float_right_type = "";
</script>
<script src="floatright.js"></script>
<SCRIPT language=JavaScript>
var ad_float_left_src = "xxx.gif";
var ad_float_left_url = "xxx.htm";
var ad_float_left_type = "";
</SCRIPT>
<SCRIPT src="floatleft_close.js"></SCRIPT>

floatright.js代码


var imgheight
window.screen.width>800 ? imgheight=550:imgheight=300
function myload()
{
myright.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
myright.style.left=document.body.offsetWidth-120;
mymove();
}
function mymove()
{
myright.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
myright.style.left=document.body.scrollLeft+document.body.offsetWidth-120;
setTimeout("mymove();",300)
}

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true)

function close_float_right(){
myright.style.visibility='hidden';
}

if(ad_float_right_type!="swf")
document.write("<div id=myright style='position: absolute;width:100;top:2;left:573;visibility: visible;z-index: 1'><a href='" + ad_float_right_url + "' target = '_blank'><img src='" + ad_float_right_src + "' WIDTH=100 HEIGHT=300 border = 0></a>");
else
document.write("<div id=myright style='position: absolute;width:100;top:2;left:573;visibility: visible;z-index: 1'><EMBED src='" + ad_float_right_src + "' quality=high WIDTH=100 HEIGHT=300 TYPE='application/x-shockwave-flash'></EMBED>");
document.write("</td></tr><tr><td width=100 height=20 align=right><a href='javascript:close_float_right();void(0);' class=closefloat>关闭</a></td></tr>"
+"</table>"
+"</div>");
myload()
hjz166 2005-01-14
  • 打赏
  • 举报
回复
可以的,自己要设置一下,根据提供的代码改改..
  • 打赏
  • 举报
回复
document.body.scrollTop关键是这句,是相对定位的这句
purple_x 2005-01-13
  • 打赏
  • 举报
回复
<script language="JavaScript1.2">
<!--
/*设置下面的参数。 设置scrollerwidth和scrollerheight参数,设置成滚动显示的图片中尺寸最大的。*/
var scrollerwidth=400
var scrollerheight=66
var scrollerbgcolor='white'
//修改下面的每个图间暂停时间,本例为3秒。
var pausebetweenimages=3000
//改变下面的图像地址,如果希望logo都是带连接的,只要将#改为相应的链接地址。
var slideimages=new Array()
slideimages[0]='<a href=#><img src="../image/05s.jpg" border=0"></a>'
slideimages[1]='<a href=#><img src="../image/04s.jpg" border=0"></a>'
slideimages[2]='<a href=#><img src="../image/03s.jpg" border=0"></a>'
slideimages[3]='<a href=#><img src="../image/02s.jpg" border=0"></a>'

//////下面的行不要编辑///////////////////////
if (slideimages.length>1)
i=2
else
i=0
function move1(whichlayer){
tlayer=eval(whichlayer)
if (tlayer.top>0&&tlayer.top<=5){
tlayer.top=0
setTimeout("move1(tlayer)",pausebetweenimages)
setTimeout("move2(document.main.document.second)",pausebetweenimages)
return
}
if (tlayer.top>=tlayer.document.height*-1){
tlayer.top-=5
setTimeout("move1(tlayer)",100)
}
else{
tlayer.top=scrollerheight
tlayer.document.write(slideimages[i])
tlayer.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}}
function move2(whichlayer){
tlayer2=eval(whichlayer)
if (tlayer2.top>0&&tlayer2.top<=5){
tlayer2.top=0
setTimeout("move2(tlayer2)",pausebetweenimages)
setTimeout("move1(document.main.document.first)",pausebetweenimages)
return
}
if (tlayer2.top>=tlayer2.document.height*-1){
tlayer2.top-=5
setTimeout("move2(tlayer2)",100)
}
else{
tlayer2.top=scrollerheight
tlayer2.document.write(slideimages[i])
tlayer2.document.close()
if (i==slideimages.length-1)
i=0
else
i++
}}
function move3(whichdiv){
tdiv=eval(whichdiv)
if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
tdiv.style.pixelTop=0
setTimeout("move3(tdiv)",pausebetweenimages)
setTimeout("move4(second2)",pausebetweenimages)
return
}
if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){
tdiv.style.pixelTop-=5
setTimeout("move3(tdiv)",100)
}
else{
tdiv.style.pixelTop=scrollerheight
tdiv.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}
}
function move4(whichdiv){
tdiv2=eval(whichdiv)
if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
tdiv2.style.pixelTop=0
setTimeout("move4(tdiv2)",pausebetweenimages)
setTimeout("move3(first2)",pausebetweenimages)
return
}
if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
tdiv2.style.pixelTop-=5
setTimeout("move4(second2)",100)
}
else{
tdiv2.style.pixelTop=scrollerheight
tdiv2.innerHTML=slideimages[i]
if (i==slideimages.length-1)
i=0
else
i++
}}
function startscroll(){
if (document.all){
move3(first2)
second2.style.top=scrollerheight
}
else if (document.layers){
move1(document.main.document.first)
document.main.document.second.top=scrollerheight+5
document.main.document.second.visibility='show'
}}
window.onload=startscroll
//-->
</script>
<ilayer id="main" width="&{scrollerwidth};" height="&{scrollerheight};" bgcolor="&{scrollerbgcolor};">
<layer id="first" left="0" top="1" width="&{scrollerwidth};">
<script language="JavaScript1.2">
if (document.layers)
document.write(slideimages[0])
</script>
</layer>
<layer id="second" left="0" top="0" width="&{scrollerwidth};" visibility="hide">
<script
language="JavaScript1.2">
if (document.layers)
document.write(slideimages[1])
</script>
</layer>
</ilayer>


<p><script language="JavaScript1.2">
<!--
if (document.all){
document.writeln('<span id="main2" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+'">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">')
document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';left:0;top:1;">')
document.write(slideimages[0])
document.writeln('</div>')
document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';left:0;top:0">')
document.write(slideimages[1])
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</span>')
}
//--></script> </p>
63712885 2005-01-13
  • 打赏
  • 举报
回复
能不能写全了!
mousejuan 2005-01-13
  • 打赏
  • 举报
回复
用的是script代码
63712885 2005-01-13
  • 打赏
  • 举报
回复
一会就消失了!
hjz166 2005-01-13
  • 打赏
  • 举报
回复

<SCRIPT FOR=window EVENT=onload LANGUAGE="JavaScript">
initAd();//載入頁面後,調用函數initAd()
</SCRIPT>
<script language="JavaScript">
<!--
function initAd() {
document.all.AdLayer.style.posTop = -200;
//設置onLoad事件激發以後,廣告層相對於固定後的y方向位置
document.all.AdLayer.style.visibility = 'visible'//設置層為可見
MoveLayer('AdLayer');//調用函數MoveLayer()
}
function MoveLayer(layerName) {
var x = 902;//浮動廣告層固定於瀏覽器的x方向位置
var y = 150;//浮動廣告層固定於瀏覽器的y方向位置
var diff = (document.body.scrollTop + y - document.all.AdLayer.style.posTop)*.40;
var y = document.body.scrollTop + y - diff;
eval("document.all." + layerName + ".style.posTop = y");
eval("document.all." + layerName + ".style.posLeft = x");//移動廣告層
setTimeout("MoveLayer('AdLayer');", 20);//設置20毫秒後再調用函數MoveLayer()
}
//-->
</script>
<!--下面為一個ID為AdLayer的層(如ID名不為AdLayer,
上面MoveLayer()內的AdLayer也要作相應修改),包括一張帶鏈接的圖片-->
<div id=AdLayer style='position:absolute; width:96px; height:151px; z-index:20; visibility:hidden;; left: 100px; top: 300px'>
<a href="http://www.visun.net/xjd/gcgfb.asp" target=_blank><img src='test.gif' border="0" height="151" width="96"></a>
</div>
63712885 2005-01-13
  • 打赏
  • 举报
回复
我问的不是那自动移动的,我问的是如何让它随滚动条移动
63712885 2005-01-13
  • 打赏
  • 举报
回复
不行啊

1,451

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计/Flash/Silverlight 开发 图象工具使用
社区管理员
  • 图象工具使用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧