第一种: </HEAD> <BODY leftMargin=0 topMargin=0> <table width="700px" border="0" align="center"> <tr height="700px"> <td><span class="STYLE1">在页面两旁随滚动条上下滚动的小广告</span></td> </tr> </table> <SCRIPT language="javascript"> function initEcAd() { document.all.AdLayer1.style.posTop = -200; document.all.AdLayer1.style.visibility = 'visible' document.all.AdLayer2.style.posTop = -200; document.all.AdLayer2.style.visibility = 'visible' MoveLeftLayer('AdLayer1'); MoveRightLayer('AdLayer2'); } function MoveLeftLayer(layerName) { var x = 5; var y = 100;// 左侧广告距离页首高度 var diff = (document.body.scrollTop + y - document.all.AdLayer1.style.posTop)*.40; var y = document.body.scrollTop + y - diff; eval("document.all." + layerName + ".style.posTop = parseInt(y)"); eval("document.all." + layerName + ".style.posLeft = x"); setTimeout("MoveLeftLayer('AdLayer1');", 20); } function MoveRightLayer(layerName) { var x = 5; var y = 100;// 右侧广告距离页首高度 var diff = (document.body.scrollTop + y - document.all.AdLayer2.style.posTop)*.40; var y = document.body.scrollTop + y - diff; eval("document.all." + layerName + ".style.posTop = y"); eval("document.all." + layerName + ".style.posRight = x"); setTimeout("MoveRightLayer('AdLayer2');", 20); } document.write("<div id=AdLayer1 style="position: absolute;visibility:hidden;z-index:1" mce_style="position: absolute;visibility:hidden;z-index:1"><a href='' target='_blank'><img src="1.gif" mce_src="1.gif" border='0'></a></div>" +"<div id=AdLayer2 style="position: absolute;visibility:hidden;z-index:1" mce_style="position: absolute;visibility:hidden;z-index:1"><a href='' target='_blank'><img src="2.gif" mce_src="2.gif" border='0'></a></div>"); initEcAd(); </SCRIPT> 第二种: <mce:script type="text/javascript"><!-- function scrollImg(){ var posX,posY; if (window.innerHeight) { posX = window.pageXOffset; posY = window.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { posX = document.documentElement.scrollLeft; posY = document.documentElement.scrollTop; } else if (document.body) { posX = document.body.scrollLeft; posY = document.body.scrollTop; } var ad=document.getElementById("ad"); ad.style.top=(posY+100)+"px"; ad.style.left=(posX+50)+"px"; setTimeout("scrollImg()",100); } // --></mce:script> <div id="ad" style="position:absolute;;width:100px;height:100px;border:1px dotted #000;text-align:center" >这里写你要输入的图片或文字</div> <mce:script type="text/javascript"><!-- scrollImg(); // --></mce:script> 还有一种对角漂浮的JavaScript: <SCRIPT LANGUAGE="JavaScript"> <!-- 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 www_helpor_net() { img.visibility = "visible"; interval = setInterval('changePos()', delay); } www_helpor_net(); //For more,visit:www.helpor.net --> </SCRIPT>