上下伸缩的js广告代码,上下伸缩的js广告代码是多少
更新:2022-11-18 00:16
本文目录一览:
- 急求一个ASP程序网站首页左右两边可以上下浮动广告代码?代码最好可以短一点。
- 网页右边跟随滚动条上下移动的小广告是怎么做的?请高手给我代码
- js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
- 网站上下的JS广告代码怎么调用啊,有没有HTML的飘浮广告代码 呀?谢谢
- 求一个页面上漂浮着两个浮动广告的js代码,就是左右两个类似春联的条形广告,能跟随着页面上下拉动
急求一个ASP程序网站首页左右两边可以上下浮动广告代码?代码最好可以短一点。
广告代码 浮动的很多
- 在网页中加入
<script language=javascript src="js/1.js"></script>
表示调用当前目录下的js目录下的1.js - 用记事本建立1.js 并保存到js目录下 并把后缀名从txt改名为js
- 1.js内容如下
var delta=0.15
var collection;
function floaters() {
this.items = [];
this.addItem = function(id,x,y,content) {
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
var newItem = {};
newItem.object = document.getElementById(id);
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function() {
collection = this.items
setInterval('play()',10);
}
}
function play() {
for(var i=0; i < collection.length; i++) {
var followObj = collection[i].object;
var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
followObj.style.left=followObj.offsetLeft+dx;
}
if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+dy;
}
followObj.style.display = '';
}
}
var theFloaters = new floaters();
theFloaters.addItem('followDiv1','document.body.clientWidth-110',230,'<a href="#" target="_blank"><img src="ad/ad001.gif" border=0/></a><br><br>');
theFloaters.addItem('followDiv2',12,230,'<a href="#" target="_blank"><img src="ad/ad002.gif" border=0/></a><br><br>');
theFloaters.play();
其中红色用所做广告地址代替 蓝色用所需要的广告图片地址代替
网页右边跟随滚动条上下移动的小广告是怎么做的?请高手给我代码
左栏浮动广告
var specialcode="<DIV id=searchspe style='Z-INDEX: 100; right: 1px; POSITION: absolute; TOP: 180px;'><TABLE cellSpacing=0 cellPadding=0 width=150 style='border-left:1px solid #2E6287;border-top:1px solid #2E6287;border-right:1px solid #2E6287;font-size:12px;color:#ffffff; border-bottom-color:#2E6287; border-bottom-width:1px'><TR bgcolor=#2E6287><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=30>关 闭</TD></TR></TABLE><table border='1' width='150' height='500' bordercolor='#2E6287'><tr><td>广告内容</td></tr></table></DIV>";
document.write(specialcode);
lastScrollY=0;
function heartBeat0() {
diffY=document.body.scrollTop;
percent=.1*(diffY-lastScrollY);
if(percent>0) percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.all.searchspe.style.pixelTop+=percent;
lastScrollY=lastScrollY+percent;
}
window.setInterval("heartBeat0()",1);
右栏浮动广告
var specialcode="<DIV id=searchspe style='Z-INDEX: 100; left: 1px; POSITION: absolute; TOP: 50px;'><TABLE cellSpacing=0 cellPadding=0 width=360 style='border-left:1px solid #333333;border-top:1px solid #333333;border-right:1px solid #333333;font-size:12px;color:#ffffff'><TR bgcolor=#2E6287><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=30>关 闭</TD></TR></TABLE><table border='1' width='150' id='table1' bordercolor='#2E6287' height='500'><tr><td>广告内容</td></tr></table></DIV>";
document.write(specialcode);
lastScrollY=0;
function heartBeat0() {
diffY=document.body.scrollTop;
percent=.1*(diffY-lastScrollY);
if(percent>0) percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.all.searchspe.style.pixelTop+=percent;
lastScrollY=lastScrollY+percent;
}
window.setInterval("heartBeat0()",1);
左栏固定广告
<DIV id=searchspe style='Z-INDEX: 100; left: 1px; POSITION: absolute; TOP: 50px;'>
<TABLE cellSpacing=0 cellPadding=0 width=360 style='border-left:1px solid #333333;border-top:1px solid #333333;border-right:1px solid #333333;font-size:12px;color:#ffffff'>
<TR bgcolor=#2E6287><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=30>关 闭</TD></TR>
</TABLE>广告内容</DIV>
右栏固定广告
<DIV id=searchspe style='Z-INDEX: 100; right: 1px; POSITION: absolute; TOP: 50px;'>
<TABLE cellSpacing=0 cellPadding=0 width=360 style='border-left:1px solid #333333;border-top:1px solid #333333;border-right:1px solid #333333;font-size:12px;color:#ffffff'>
<TR bgcolor=#2E6287><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=30>关 闭</TD></TR>
</TABLE>广告内容</DIV>
漂浮广告代码
<div id="img" style="position:absolute; width: 200; height: 151">广告内容</div>
<script LANGUAGE="JavaScript">
var xPos = 20;
var yPos = 10;
img.style.left= xPos;
img.style.top = yPos;
var step = 1;
var delay = 30;
var width,height,Hoffset,Woffset;
var y = 1;
var x = 1;
var interval;
img.visibility = "visible";
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
if (y) {
yPos = yPos + step;
} else {
yPos = yPos - step;
}
if (yPos < 0) {
y = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
y = 0;
yPos = (height - Hoffset);
}
if (x) {
xPos = xPos + step;
} else {
xPos = xPos - step;
}
if (xPos < 0) {
x = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
x = 0;
xPos = (width - Woffset);
}
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;
}
function start() {
interval = setInterval('changePos()', delay);
}
function pause_resume() {
clearInterval(interval);
}
start();
</script>
固定对联
<DIV id=searchspe style='Z-INDEX: 100; right: 5px; POSITION: absolute; TOP: 50px;'>
<TABLE cellSpacing=0 cellPadding=0 width=150 style='font-size:12px;color:#ffffff'>
<TR bgcolor=#C54A00><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick=searchspe.style.visibility='hidden' width=30>关 闭</TD></TR>
</TABLE>广告内容</DIV>
<DIV id=searchspe2 style='Z-INDEX: 100; left: 5px; POSITION: absolute; TOP: 50px;'>
<TABLE cellSpacing=0 cellPadding=0 width=150 style='font-size:12px;color:#ffffff'>
<TR bgcolor=#12BDFF><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick=searchspe2.style.visibility='hidden' width=30>关 闭</TD></TR>
</TABLE>广告内容</DIV>
随动对联
function close163news() {
searchspe.style.visibility='hidden';
searchspe2.style.visibility='hidden';
}
var specialcode="<DIV id=searchspe style='Z-INDEX: 100; right: 1px; POSITION: absolute; TOP: 30px;'><TABLE cellSpacing=0 cellPadding=0 width=150 style='font-size:12px;color:#ffffff'><TR bgcolor=#C54A00><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick='close163news()' width=30>关 闭</TD></TR></TABLE>广告内容</DIV>";
document.write(specialcode);
lastScrollX=0;
function heartBeat0() {
diffY=document.body.scrollTop;
percent=.1*(diffY-lastScrollX);
if(percent>0) percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.all.searchspe.style.pixelTop+=percent;
lastScrollX=lastScrollX+percent;
}
window.setInterval("heartBeat0()",1);
var specialcode2="<DIV id=searchspe2 style='Z-INDEX: 100; left: 1px; POSITION: absolute; TOP: 30px;'><TABLE cellSpacing=0 cellPadding=0 width=150 style='font-size:12px;color:#ffffff'><TR bgcolor=#12BDFF><TD height=20> 推荐↓</TD><TD style='CURSOR: hand' onclick='close163news()' width=30>关 闭</TD></TR></TABLE>广告内容</DIV>";
document.write(specialcode2);
lastScrollY=0;
function heartBeat1() {
diffY=document.body.scrollTop;
percent=.1*(diffY-lastScrollY);
if(percent>0) percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.all.searchspe2.style.pixelTop+=percent;
lastScrollY=lastScrollY+percent;
}
window.setInterval("heartBeat1()",1);
qq好友上线广告代码
<!-- 代码开始 请将下面的代码放到body结束标签之前 -->
<DIV id=eMeng style="BORDER-RIGHT: #455690 1px solid; BORDER-TOP: #a6b4cf 1px solid; Z-INDEX: 99999; LEFT: 64px; VISIBILITY: hidden; BORDER-LEFT: #a6b4cf 1px solid; WIDTH: 168px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 374px; HEIGHT: 115px; BACKGROUND-COLOR: #c9d3f3">
<TABLE style="BORDER-TOP: #ffffff 1px solid; BORDER-LEFT: #ffffff 1px solid" cellSpacing=0 cellPadding=0 width="100%" bgColor=#cfdef4 border=0>
<TBODY>
<TR>
<TD style="FONT-SIZE: 12px; BACKGROUND-IMAGE: none; COLOR: #0f2c8c" width=30 height=24></TD>
<TD style="PADDING-LEFT: 4px; FONT-WEIGHT: normal; FONT-SIZE: 12px; BACKGROUND-IMAGE: none; COLOR: #1f336b; PADDING-TOP: 4px" vAlign=center width="100%"><span class="style13">本站提示</span></TD>
<TD vAlign=center align=right width=19><SPAN title=关闭 style="FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px" onclick=closeDiv()>×</SPAN></TD>
</TR>
<TR>
<TD style="PADDING-RIGHT: 1px; BACKGROUND-IMAGE: none; PADDING-BOTTOM: 1px" colSpan=3 height=90>
<DIV style="BORDER-RIGHT: #b9c9ef 1px solid; PADDING-RIGHT: 13px; BORDER-TOP: #728eb8 1px solid; PADDING-LEFT: 13px; FONT-SIZE: 12px; PADDING-BOTTOM: 13px; BORDER-LEFT: #728eb8 1px solid; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 18px; BORDER-BOTTOM: #b9c9ef 1px solid; HEIGHT: 100%">
<div align="left"> <span style="text-decoration: none"><FONT color=#FF0000>仿造qq好友上线</FONT><br><center></center></span></div>
</DIV>
</td>
</tr>
</table>
</div>
<script language=JavaScript>
window.onload = getMsg;
window.onresize = resizeDiv;
window.onerror = function(){};
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg() {
try {
divTop = parseInt(document.getElementById("eMeng").style.top,10);
divLeft = parseInt(document.getElementById("eMeng").style.left,10);
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;
document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
document.getElementById("eMeng").style.visibility="visible";
objTimer = window.setInterval("moveDiv()",10);
} catch(e) {}
}
function resizeDiv() {
try {
divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10);
document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10);
} catch(e) {}
}
function moveDiv() {
try {
if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10))) {
window.clearInterval(objTimer);
objTimer = window.setInterval("resizeDiv()",1);
}
divTop = parseInt(document.getElementById("eMeng").style.top,10);
document.getElementById("eMeng").style.top = divTop - 1;
} catch(e) {}
}
function closeDiv() {
document.getElementById('eMeng').style.visibility='hidden';
if(objTimer) window.clearInterval(objTimer);
}
</script>
<!-- 代码复制结束 -->
js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
随滚动而滚动,css就可以实现,也就是固定在屏幕固定位置,用 position:fixed;
即可,关闭按钮可以用 document.getElementById('').style.display='none';
即可,如
<div style="width:500px; height:200px; background-color:#F00;position:fixed;left:100px;top:200px;" id="test">
<button onclick="document.getElementById('test').style.display='none';">关闭</button>
</div>
其中left和top都是相对于屏幕的位置
网站上下的JS广告代码怎么调用啊,有没有HTML的飘浮广告代码 呀?谢谢
这是我做网站是用到的漂浮代码。
<html>
<head>
</head>
<body>
<div id="img" style="position:absolute; width: 200; height: 151"><img src="/chatroom/image/1.jpg" border="0"/></div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><......
var xPos = 20;
var yPos = 10;
img.style.left= xPos;
img.style.top = yPos;
var step = 1;
var delay = 30;
var width,height,Hoffset,Woffset;
var y = 1;
var x = 1;
var interval;
img.visibility = "visible";
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
if (y) {
yPos = yPos + step;
} else {
yPos = yPos - step;
}
if (yPos < 0) {
y = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
y = 0;
yPos = (height - Hoffset);
}
if (x) {
xPos = xPos + step;
} else {
xPos = xPos - step;
}
if (xPos < 0) {
x = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
x = 0;
xPos = (width - Woffset);
}
img.style.left = xPos + document.body.scrollLeft;
img.style.top = yPos + document.body.scrollTop;
}
function start() {
interval = setInterval('changePos()', delay);
}
function pause_resume() {
clearInterval(interval);
}
start();
求一个页面上漂浮着两个浮动广告的js代码,就是左右两个类似春联的条形广告,能跟随着页面上下拉动
你吧DEMO下载下来,看看是怎么回事。。不要拷贝我贴上来的JS。好吧。。。。 可下载DEMO下来自己琢磨一下 JS :
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='' 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='' 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() {
lovinxin1.style.visibility="hidden";
lovinxin2.style.visibility="hidden";
}
window.setInterval("heartBeat()",1);