functioninitEcAd(){document
all
AdLayer1
style
posTop=-200document
all
AdLayer1
style
visibility='visible'document
all
AdLayer2
style
posTop=-200document
all
AdLayer2
style
visibility='visible'MoveLeftLayer('AdLayer1')MoveRightLayer('AdLayer2')}functionMoveLeftLayer(layerName){varx=5vary=165vardiff=(document
body
scrollTop+y-document
all
AdLayer1
style
posTop)*
40vary=document
body
scrollTop+y-diffeval("document
all
"+layerName+"
style
posTop=y")eval("document
all
"+layerName+"
style
posLeft=x")setTimeout("MoveLeftLayer('AdLayer1')",20)}functionMoveRightLayer(layerName){varx=5vary=165vardiff=(document
body
scrollTop+y-document
all
AdLayer2
style
posTop)*
40vary=document
body
scrollTop+y-diffeval("document
all
"+layerName+"
style
posTop=y")eval("document
all
"+layerName+"
style
posRight=x")setTimeout("MoveRightLayer('AdLayer2')",20)}document
write("<divid=AdLayer1style='position:absolutevisibility:hiddenz-index:1'><ahref=连接地址target=_blank><imgsrc=图片地址border=0></a></div>"+"<divid=AdLayer2style='position:absolutevisibility:hiddenz-index:1'><ahref=连接地址target=_blank><imgsrc=图片地址border=0></a></div>")initEcAd()把上面的代码另存为一个*
JS文件,然后在想实现此效果的页面<head></head>之间加上一列代码:<SCRIPTFOR='EccoolAd'EVENT='fscommand()'LANGUAGE='JavaScript'>AdLayer1
style
visibility='hidden'AdLayer2
style
visibility='hidden'</script><scriptsrc=*
js></script>嘿嘿把分给我吧
<html><head>
<meta http-equiv="content-type" content="text/htmlcharset=utf-8">
<title>右侧浮动窗口代码演示</title>
</head>
<body>
<table height=1000><tr><td>演示效果看右侧,右侧调用页面为right.htm</td></tr></table>
<!-- 浮动广告代码开始 -->
<div id="ShowAD" style="position:absolutez-index: 100">
<div style="width:155height:18pxfont-size:14pxfont-weight:boldtext-align:leftCURSOR: hand" onClick="closead()"><font
color=ff0000>关闭</font></div>
<IFRAME allowTransparency="true" marginwidth=0 marginheight=0 src="right.htm" frameborder=0 width=155 scrolling=no
height=530></IFRAME>
</div>
<script>
var bodyfrm = ( document.compatMode.toLowerCase()=="css1compat" ) ? document.documentElement : document.body
var adst = document.getElementById("ShowAD").style
adst.top = ( bodyfrm.clientHeight -530-22 ) + "px"
adst.left = ( bodyfrm.clientWidth -155 ) + "px"
function moveR() {
adst.top = ( bodyfrm.scrollTop + bodyfrm.clientHeight - 530-22) + "px"
adst.left = ( bodyfrm.scrollLeft + bodyfrm.clientWidth - 155 ) + "px"
}
setInterval("moveR()", 80)
function closead()
{
adst.display='none'
}
</script>
<!-- 浮动广告代码结束 -->
</body>
</html>
漂浮广告用如下代码:
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>js实现可关闭的自由漂浮广告代码_js特效_特效代码_www.xunmzy.com</title>
<meta http-equiv="content-type" content="text/htmlcharset=utf-8">
<style type="text/css">
#img1{width:autoposition:absolutetop:43pxleft:2pxz-index:10}
#img1 div{width:autotext-align:rightfont-size:12px}
#img1 div a:link{text-decoration:none}
#img1 div a:hover{color:redtext-decoration:none}
#img1 img{width:autoborder:1px solid black}
p{margin-top:50pxtext-align:center}
</style>
</head>
<body>
<div id="img1" onmouseover="pause_resume()" onmouseout="pause_resume()">
<div><a href="javascript:void(0)" onclick="closediv()" title="点击关闭">关闭</a></div>
<a href="https://www.xunmzy.com/" target="_blank"><img src="images/logo_png.png" alt="js实现可关闭的自由漂浮广告代码"></a>
</div>
<p>js代码可关闭的自由漂浮的图片广告特效</p>
<script type="text/javascript">
var xPos = 300
var yPos = 200
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
var divid = img1 //浮动DIV的ID.
divid.style.top = yPos
function changePos(){
width = document.body.clientWidth
height = document.body.clientHeight
Hoffset = divid.offsetHeight
Woffset = divid.offsetWidth
divid.style.left = xPos + document.body.scrollLeft
divid.style.top = yPos + document.body.scrollTop
if(yon){yPos = yPos + step}else{yPos = yPos - step}
if(yPos < 0){yon = 1yPos = 0}
if(yPos >= (height - Hoffset)){yon = 0 yPos = (height - Hoffset)}
if(xon){xPos = xPos + step}else{xPos = xPos - step}
if(xPos < 0){xon = 1xPos = 0}
if(xPos >= (width - Woffset)){xon = 0 xPos = (width - Woffset)}
}
function start(){
divid.visibility = "visible"
interval = setInterval('changePos()',delay)
}
function pause_resume(){
if(pause){
clearInterval(interval)
pause = false}
else{
interval = setInterval('changePos()',delay)
pause = true
}
}
function closediv(){
clearInterval(interval)
divid.style.display = "none"
}
start()
</script>
</body>
</html>
把需要改的地方改了就可以了,
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)