js两侧可关闭的对联广告代码(效果图)

发布时间:2020-11-15编辑:脚本学堂
一例js实现的左右两侧可关闭的对联广告代码,以前见过的js对联广告,有的不可关闭,有的仅能同时关闭一侧的广告代码,这个js对联广告代码,可以实现同时关闭左右两侧的对联。

左右两侧可关闭的对联广告,效果图:

对联广告

用到的图片:
对联广告原图1  对联广告原图2

例子,左右两侧可同时关闭的对联广告。
 

复制代码 代码示例:

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>可关闭的对联广告_脚本学堂</title>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language=javascript>
suspendcode="<div id=lovexin1 style='z-index: 10; left: 6px; position: absolute; top: 105px; width: 100; height: 300px;'><img src='images/close.gif' onclick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='http://www.jb200.com/' target='_blank'><img src='images/ad_100x300.jpg' width='100' height='300' border='0'></a></div>"
document.write(suspendcode);

suspendcode="<div id=lovexin2 style='z-index: 10; left: 896px; position: absolute; top: 105px; width: 100; height: 300px;'><img src='images/close.gif' onclick='javascript:window.hide()' width='100' height='14' border='0' vspace='3' alt='关闭对联广告'><a href='http://www.jb200.com/' target='_blank'><img src='images/ad_100x300.jpg' width='100' height='300' border='0'></a></div>"
document.write(suspendcode);

//flash格式调用方法
//<embed src='flash.swf' quality=high  width=100 height=300 type='application/x-shockwave-flash' id=ad wmode=opaque></embed>

lastscrolly=0;
function heartbeat(){
diffy=document.body.scrolltop;
percent=.3*(diffy-lastscrolly);
if(percent>0)percent=math.ceil(percent);
else percent=math.floor(percent);
document.all.lovexin1.style.pixeltop+=percent;
document.all.lovexin2.style.pixeltop+=percent;
lastscrolly=lastscrolly+percent;
}
function hide() 
{  
lovexin1.style.visibility="hidden";
lovexin2.style.visibility="hidden";
}
window.setinterval("heartbeat()",1);
</script>
<table width="778" height="1000" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f4f4f4">
  <tr>
<td align="center" valign="top"><br>
<p>左右两侧可关闭的对联广告</p>
<p></p></td>
  </tr>
</table>
</body>
</html>