请问谁有右侧漂浮的代码,是JS代码

JavaScript012

请问谁有右侧漂浮的代码,是JS代码,第1张

我有 但是是左右2边的 你直接复制 然后放在JS文件里 lastScrollY = 0function heartBeat(){ var diffYif (document.documentElement &&document.documentElement.scrollTop) diffY = document.documentElement.scrollTopelse if (document.body) diffY = document.body.scrollTop else {/*Netscape stuff*/} //alert(diffY)percent=.1*(diffY-lastScrollY)if(percent>0)percent=Math.ceil(percent)else percent=Math.floor(percent)document.getElementById("leftDiv").style.top = parseInt(document.getElementById("leftDiv").style.top)+percent+"px"document.getElementById("rightDiv").style.top = parseInt(document.getElementById("rightDiv").style.top)+percent+"px"lastScrollY=lastScrollY+percent//alert(lastScrollY)} //下面这段删除后,对联将不跟随屏幕而移动。 window.setInterval("heartBeat()",1)//-->//关闭按钮 function close_left1(){ // left1.style.visibility='hidden'left1.style.display='none'leftDiv.style.display='none'} function close_right1(){ //right1.style.visibility='hidden'right1.style.display='none'rightDiv.style.display='none'} //显示样式 document.writeln("<style type=\"text\/css\">")document.writeln("#leftDiv,#rightDiv{width:100pxheight:100pxbackground-color:#fffposition:absolute}")document.writeln(".itemFloat{width:100pxheight:autoline-height:5px}")document.writeln("<\/style>")//以下为主要内容 document.writeln("<div id=\"leftDiv\" style=\"top:40pxleft:5px\">")//------左侧各块开始 //---L1 document.writeln("<div id=\"left1\" class=\"itemFloat\">")document.writeln("<a href='freecalls_business.aspx'><img src=images\\index_ad_3_min.jpg width=100 height=300 /></a>")document.writeln("<br><a href=\"javascript:close_left1()\" title=\"关闭广告\">×<\/a><br><br><br><br>")document.writeln("<\/div>")//------左侧各块结束 document.writeln("<\/div>")document.writeln("<div id=\"rightDiv\" style=\"top:40pxright:5px\">")//------右侧各块结束 //---R1 document.writeln("<div id=\"right1\" class=\"itemFloat\">")document.writeln("<a href='huodong_kaixue.html'><img src=images\\index_ad_4_min.jpg width=100 height=300 /></a>")document.writeln("<br><a href=\"javascript:close_right1()\" title=\"关闭广告\">×<\/a><br><br><br><br>")document.writeln("<\/div>")//------右侧各块结束 document.writeln("<\/div>")

记得采纳啊

下面的代码调试通过,满足你的要求:

<div id="ad" style="position:absolute">

<a href="abc/abcd.htm" target="_blank">

<img src="PIC_0886.jpg" border="0">

</a></div>

<script>

var x = 50,y = 60

var xin = true, yin = true

var step = 1

var delay = 10

var obj=document.getElementById("ad")

function floatAD() {

var L=T=0

var R= document.body.clientWidth-obj.offsetWidth

var B = document.body.clientHeight-obj.offsetHeight

obj.style.left = x + document.body.scrollLeft

obj.style.top = y + document.body.scrollTop

x = x + step*(xin?1:-1)

if (x <L) { xin = truex = L}

if (x >R){ xin = falsex = R}

y = y + step*(yin?1:-1)

if (y <T) { yin = truey = T }

if (y >B) { yin = falsey = B }

}

var itl= setInterval("floatAD()", delay)

obj.onmouseover=function(){clearInterval(itl)}

obj.onmouseout=function(){itl=setInterval("floatAD()", delay)}

setTimeout("clearInterval(itl)ad.style.display='none'",5000)

</script>

你以前的代码第一行是多的,应该删除,我增加的一行实现5秒后取消,你把5000改为15000就能15秒取消。