可以关闭的浮动广告代码(悬浮广告代码)
admin 发布:2022-12-19 18:35 157
今天给各位分享可以关闭的浮动广告代码的知识,其中也会对悬浮广告代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
- 2、带关闭的漂浮广告代码
- 3、关于网页上的浮动广告,想加个关闭广告的代码进去
- 4、帮我这个浮动广告加个关闭按钮代码(代码如下)
- 5、帮我这个手机底部浮动广告加上关闭按钮代码,高手指点下,谢谢!
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代码实现对联式浮动广告演示!
self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function heartBeat() {
if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelTop += percent;
if(NS) document.floater.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelLeft += percent;
if(NS) document.floater.left += percent;
lastScrollX = lastScrollX + percent;
}
}
function checkFocus(x,y) {
stalkerx = document.floater.pageX;
stalkery = document.floater.pageY;
stalkerwidth = document.floater.clip.width;
stalkerheight = document.floater.clip.height;
if( (x stalkerx x (stalkerx+stalkerwidth)) (y stalkery y (stalkery+stalkerheight))) return true;
else return false;
}
function grabIt(e) {
if(IE) {
whichIt = event.srcElement;
while (whichIt.id.indexOf("floater") == -1) {
whichIt = whichIt.parentElement;
if (whichIt == null) { return true; }
}
whichIt.style.pixelLeft = whichIt.offsetLeft;
whichIt.style.pixelTop = whichIt.offsetTop;
currentX = (event.clientX + document.body.scrollLeft);
currentY = (event.clientY + document.body.scrollTop);
} else {
window.captureEvents(Event.MOUSEMOVE);
if(checkFocus (e.pageX,e.pageY)) {
whichIt = document.floater;
StalkerTouchedX = e.pageX-document.floater.pageX;
StalkerTouchedY = e.pageY-document.floater.pageY;
}
}
return true;
}
function moveIt(e) {
if (whichIt == null) { return false; }
if(IE) {
newX = (event.clientX + document.body.scrollLeft);
newY = (event.clientY + document.body.scrollTop);
distanceX = (newX - currentX); distanceY = (newY - currentY);
currentX = newX; currentY = newY;
whichIt.style.pixelLeft += distanceX;
whichIt.style.pixelTop += distanceY;
if(whichIt.style.pixelTop document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
if(whichIt.style.pixelLeft document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
if(whichIt.style.pixelLeft document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
if(whichIt.style.pixelTop document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
event.returnValue = false;
} else {
whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
if(whichIt.left 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
if(whichIt.top 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
if( (whichIt.left + whichIt.clip.width) = (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
if( (whichIt.top + whichIt.clip.height) = (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
return false;
}
return false;
}
function dropIt() {
whichIt = null;
if(NS) window.releaseEvents (Event.MOUSEMOVE);
return true;
}
!-- DRAG Drop CODE --
if(NS) {
window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
window.onmousedown = grabIt;
window.onmousemove = moveIt;
window.onmouseup = dropIt;
}
if(NS || IE) action = window.setInterval("heartBeat()",1);
将以上内容保存到一个文件:code.js,将以下内容放到广告的页面,修改test.jpg,改成自己的图片或者FLASH文件
SCRIPT language="javascript" src="code.js"/SCRIPT
div id="floater" style="left:11px;top: 98px;width:100%;position: absolute;visibility:visible;z-index:1"
div id="dllayer3" style="left:0px; position: absolute; visibility:visible; z-index:2; width: 101px; height: 286px;"img src="test.jpg" width="80" height="100" border="0"
/div
div id=dllayer2 style='right:0px; position: absolute; visibility:visible; z-index:2; left: 875px; top: 0px; width: 80px; height: 100px;'img src="test.jpg" width="80" height="100" border="0"/div
/div
关于网页上的浮动广告,想加个关闭广告的代码进去
这里有一个浮动层效果
有关闭按钮功能
能自定义定位并随屏滚动而不抖动
还可以设置居中
里面有教程和源码
帮我这个浮动广告加个关闭按钮代码(代码如下)
div id="adver"a href="?
mod=aboutitem=trainingclass" target="_blank"img border="0"
src="
66634de1.jpg"/a/div
div id="adver1"a href=";act=defaultitem=CommissionReward" target="_blank"img border="0" src=""/a/div
script type="text/javascript"
!--
//公共脚本文件 main.js
function addEvent(obj,evtType,func,cap){
cap=cap||false;
if(obj.addEventListener){
obj.addEventListener(evtType,func,cap);
return true;
}else if(obj.attachEvent){
if(cap){
obj.setCapture();
return true;
}else{
return obj.attachEvent("on" + evtType,func);
}
}else{
return false;
}
}
function removeEvent(obj,evtType,func,cap){
cap=cap||false;
if(obj.removeEventListener){
obj.removeEventListener(evtType,func,cap);
return true;
}else if(obj.detachEvent){
if(cap){
obj.releaseCapture();
return true;
}else{
return obj.detachEvent("on" + evtType,func);
}
}else{
return false;
}
}
function getPageScroll(){
var xScroll,yScroll;
if (self.pageXOffset) {
xScroll = self.pageXOffset;
} else if (document.documentElement
document.documentElement.scrollLeft){
xScroll = document.documentElement.scrollLeft;
} else if (document.body) {
xScroll = document.body.scrollLeft;
}
if (self.pageYOffset) {
yScroll = self.pageYOffset;
} else if (document.documentElement document.documentElement.scrollTop){
yScroll = document.documentElement.scrollTop;
} else if (document.body) {
yScroll = document.body.scrollTop;
}
arrayPageScroll = new Array(xScroll,yScroll);
return arrayPageScroll;
}
function GetPageSize(){
var xScroll, yScroll;
if (window.innerHeight window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight document.body.offsetHeight){
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else {
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) {
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement
document.documentElement.clientHeight) {
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) {
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
if(yScroll windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if(xScroll windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
var AdMoveConfig=new Object();
AdMoveConfig.IsInitialized=false;
AdMoveConfig.AdCount=0;
AdMoveConfig.ScrollX=0;
AdMoveConfig.ScrollY=0;
AdMoveConfig.MoveWidth=0;
AdMoveConfig.MoveHeight=0;
AdMoveConfig.Resize=function(){
var winsize=GetPageSize();
AdMoveConfig.MoveWidth=winsize[2];
AdMoveConfig.MoveHeight=winsize[3];
AdMoveConfig.Scroll();
}
AdMoveConfig.Scroll=function(){
var winscroll=getPageScroll();
AdMoveConfig.ScrollX=winscroll[0];
AdMoveConfig.ScrollY=winscroll[1];
}
addEvent(window,"resize",AdMoveConfig.Resize);
addEvent(window,"scroll",AdMoveConfig.Scroll);
function AdMove(id,addCloseButton){
if(!AdMoveConfig.IsInitialized){
AdMoveConfig.Resize();
AdMoveConfig.IsInitialized=true;
}
AdMoveConfig.AdCount++;
var obj=document.getElementById(id);
obj.style.position="absolute";
var W=AdMoveConfig.MoveWidth-obj.offsetWidth;
var H=AdMoveConfig.MoveHeight-obj.offsetHeight;
var x = W*Math.random(),y = H*Math.random();
var rad=(Math.random()+1)*Math.PI/6;
var kx=Math.sin(rad),ky=Math.cos(rad);
var dirx = (Math.random()0.5?1:-1), diry = (Math.random()0.5?1:-1);
var step = 1;
var interval;
if(addCloseButton){
var closebtn=document.createElement("div");
obj.appendChild(closebtn);
closebtn.style.position="absolute";
closebtn.style.top="1px";
closebtn.style.left=(obj.offsetWidth-28) + "px";
closebtn.style.width="24px";
closebtn.style.height="12px";
closebtn.style.borderStyle="solid";
closebtn.style.borderWidth="1px";
closebtn.style.borderColor="#000";
closebtn.style.backgroundColor="#fff";
closebtn.style.fontSize="12px";
closebtn.style.color="#000";
closebtn.style.cursor="pointer";
closebtn.innerHTML="关闭";
closebtn.onclick=function(){
obj.style.display="none";
clearInterval(interval);
closebtn.onclick=null;
obj.onmouseover=null;
obj.onmouseout=null;
obj.MoveHandler=null;
AdMoveConfig.AdCount--;
if(AdMoveConfig.AdCount=0){
removeEvent(window,"resize",AdMoveConfig.Resize);
removeEvent(window,"scroll",AdMoveConfig.Scroll);
AdMoveConfig.Resize=null;
AdMoveConfig.Scroll=null;
AdMoveConfig=null;
}
}
}
obj.MoveHandler=function(){
obj.style.left = (x + AdMoveConfig.ScrollX) + "px";
obj.style.top = (y + AdMoveConfig.ScrollY) + "px";
rad=(Math.random()+1)*Math.PI/6;
W=AdMoveConfig.MoveWidth-obj.offsetWidth;
H=AdMoveConfig.MoveHeight-obj.offsetHeight;
x = 0;
y = y + step*ky*diry;
if (y 0){diry = 1;y = 0;kx=Math.sin(rad);ky=Math.cos(rad);}
if (y H){diry = -1;y = H;kx=Math.sin(rad);ky=Math.cos(rad);}
}
this.SetLocation=function(vx,vy){x=vx;y=vy;}
this.SetDirection=function(vx,vy){dirx=vx;diry=vy;}
this.Run=function(){
var delay = 10;
interval=setInterval(obj.MoveHandler,delay);
obj.onmouseover=function(){clearInterval(interval);}
obj.onmouseout=function(){interval=setInterval(obj.MoveHandler, delay);}
}
}
//--
/script
/head
body
script type="text/javascript"
!--
var ad1=new AdMove("adver",true);
ad1.Run();
var ad2=new AdMove("adver1",true);
ad2.Run();
//--
/script
帮我这个手机底部浮动广告加上关闭按钮代码,高手指点下,谢谢!
public ListBars pageListTwo(int currentPage, int showRows)
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
ArrayListBars resultList = new ArrayListBars();
try
{
可以关闭的浮动广告代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于悬浮广告代码、可以关闭的浮动广告代码的信息别忘了在本站进行查找喔。
版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;
- 上一篇:轮显代码(轮显是什么意思)
- 下一篇:手机网站样式代码(手机端网页代码)
相关推荐
- 05-04网站右下角视频代码(网页视频右上角下载)[20240504更新]
- 05-04软件公司代码管理软件(软件产品代码)[20240504更新]
- 05-04js提示气球代码(js提示气球代码不可用)[20240504更新]
- 05-04电商前台代码(电商前台代码是什么)[20240504更新]
- 05-04项目代码查询(建设项目代码查询)[20240504更新]
- 05-04用户注册关键代码(用户登录注册代码)[20240504更新]
- 05-04jq滑块验证代码(滑块验证怎么操作)[20240504更新]
- 05-03关于html5实例代码的信息[20240503更新]
- 05-03js广告代码对量(js底部悬浮广告代码)[20240503更新]
- 05-03禅道源代码与一键有什么区别(禅道开源版怎么样)[20240503更新]
取消回复欢迎 你 发表评论:
- 标签列表
- 最近发表
- 友情链接