商道通企业营销问诊监理平台,帮您找到好专家!
企业网络营销服务
咨询热线: 18954161236

当前位置:首页  >  营销百科  >  营销通  >  带关闭网页漂浮广告js代码

带关闭网页漂浮广告js代码

投稿人:小商君 2016-12-28 13:49:00 2456

文章摘要: 网页漂浮广告代码,带关闭漂浮广告代码,js漂浮广告代码,漂浮广告用什么方法?现在小编为大家提供漂浮广告代码。1、javascript漂浮在网页上的广告代码<html><head><metah

    网页漂浮广告代码,带关闭漂浮广告代码,js漂浮广告代码,漂浮广告用什么方法?现在小编为大家提供漂浮广告代码。
    
    1、javascript漂浮在网页上的广告代码

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Js弹性漂浮广告代码</title>
</head>
<body>
<DIV id=img1 style="Z-INDEX: 100; LEFT: 2px; WIDTH: 59px; POSITION: absolute; TOP: 43px; HEIGHT: 61px;
 visibility: visible;"><a href="/" target="_blank"><img  src="/jscss/demoimg/201207/pic.gif" width="80" height="80" border="0"></a></DIV>
<SCRIPT language="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;
img1.style.top = yPos;
function changePos() 
{
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img1.offsetHeight;
Woffset = img1.offsetWidth;
img1.style.left = xPos + document.body.scrollLeft;
img1.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 start()
{
img1.visibility = "visible";
interval = setInterval('changePos()', delay);
}
function pause_resume() 
{
if(pause) 
{
clearInterval(interval);
pause = false;}
else 
{
interval = setInterval('changePos()',delay);
pause = true; 
}
}
start();
</SCRIPT>
</body>
</html></td>
 </tr>
</table>
    
    2、带关闭漂浮广告代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>可关闭的自由漂浮的图片广告特效代码</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<style type="text/css">
#img1{width:59px;height:61px;position:absolute;top:43px;left:2px;z-index:10;}
#img1 div{width:80px;text-align:right;font-size:12px;}
#img1 div a:link{text-decoration:none;}
#img1 div a:hover{color:red;text-decoration:none;}
#img1 img{width:80px;height:80px;border:1px solid black;}
p{margin-top:50px;text-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="http://www.msxindl.com/" target="_blank"><img src="/texiao/images/nopic.jpg" alt="可关闭的自由漂浮的图片广告特效代码"></a>
</div>
<p>可关闭的自由漂浮的图片广告特效</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 = 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 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>
    
    3、js漂浮广告代码

<script>
lastScrollY=0;
function heartBeat(neryid){
var diffY;
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop
else
{/*Netscape stuff*/}
percent=.1*(diffY-lastScrollY);
if(percent>0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById(neryid).style.top=parseInt(document.getElementById(neryid).style.top)+percent+"px";
lastScrollY=lastScrollY+percent;
}
function hidethis(neryid){
document.getElementById(neryid).style.visibility="hidden";
}
window.setInterval("heartBeat('goods')",1);
</script>
复制代码
2,html部分
<div id="goods" style="width:50px; height:300px; position:absolute; background-color:yellow; right: 10px; top: 200px;">
此处旋转内容,然后测试悬浮广告的效果。
</div>

分享到:
©2012-2020 商道通在线(北京)科技有限公司 版权所有 京ICP备17039987号-1

京公网安备 11010502030885号

用户登录

Sign in
*
*
  忘记密码?
  如果您是新用户,请点击这里注册
 

友情提示

您的余额不足,请到充值中心充值或选择其他版本

立即充值