flash对联广告代码

为了做好对联广告,从网上下过一些相关代码,都不是那么太好用,在老公的帮助下精简了JS代码,特整理出来以备将来拿来就用。(我觉得这个的好处就是可以自动适应宽屏和普屏分辨率,用不着为广告的定位费半天劲了。)

	function hide(){
		document.getElementById('adLeft').style.visibility='hidden';
		document.getElementById('adRight').style.visibility='hidden';
	}
	lastScrollY=0;
	function heartBeat(){ 
		var diffY;
		if (document.documentElement && document.documentElement.scrollTop){
			diffY = document.documentElement.scrollTop;
		}else 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("adLeft").style.top=parseInt(document.getElementById("adLeft").style.top)+percent+"px";
		document.getElementById("adRight").style.top=parseInt(document.getElementById("adLeft").style.top)+percent+"px";
		lastScrollY=lastScrollY+percent; 
	}
	if(window.screen.width==1280){
		if(document.body.clientWidth>=1024){
			suspendcode12="<DIV id=\"adLeft\" style='left:55px;POSITION:absolute;TOP:150px;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='90' height='270'><param name='movie' value='images/ad.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='images/ad.swf' width='90' height='270' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed></object><a href='#' οnclick='hide();'><img src='images/close.gif' border='0' /></a></div>";
			suspendcode14="<DIV id=\"adRight\" style='right:55px;POSITION:absolute;TOP:150px;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='90' height='270'><param name='movie' value='images/ad.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='images/ad.swf' width='90' height='270' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed></object><a href='#' οnclick='hide();'><img src='images/close.gif' border='0' /></a></div>";
		}else{
			suspendcode12="<DIV id=\"adLeft\" style='left:5px;POSITION:absolute;TOP:150px;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='90' height='270'><param name='movie' value='images/ad.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='images/ad.swf' width='90' height='270' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed></object><a href='#' οnclick='hide();'><img src='images/close.gif' border='0' /></a></div>";
			suspendcode14="<DIV id=\"adRight\" style='right:5px;POSITION:absolute;TOP:150px;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='90' height='270'><param name='movie' value='images/ad.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='images/ad.swf' width='90' height='270' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed></object><a href='#' οnclick='hide();'><img src='images/close.gif' border='0' /></a></div>";
		}
	}else{
		suspendcode12="<DIV id=\"adLeft\" style='left:5px;POSITION:absolute;TOP:150px;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='90' height='270'><param name='movie' value='images/ad.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='images/ad.swf' width='90' height='270' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed></object><a href='#' οnclick='hide();'><img src='images/close.gif' border='0' /></a></div>";
		suspendcode14="<DIV id=\"adRight\" style='right:5px;POSITION:absolute;TOP:150px;'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='90' height='270'><param name='movie' value='images/ad.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='images/ad.swf' width='90' height='270' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed></object><a href='#' οnclick='hide();'><img src='images/close.gif' border='0' /></a></div>";
	}
	
	document.write(suspendcode12); 
	document.write(suspendcode14); 
	window.setInterval("heartBeat()",2);

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>滚动FLASH对联广告</title>
<style>
<!--
#adLeft,#adRight{
width:90px;
height:270px;
z-index:1000;
border:1px solid #ccc;
}
#wrap {
height:1000px; 
width:780px; 
border:1px solid #ccc; 
margin:0 auto
}
-->
</style>
</head>
<body>
<DIV id=wrap></DIV>
<script language="javascript" src="js/adv.js"></script>
</body>
</html>

 这里我引用了两个images/文件,ad.swf和close.gif,用到具体的地方相关DIV的属性还需要再酌情添加修改,这个懒不能偷。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值