JS漂浮广告代码
各类漂浮广告代码、弹窗广告代码大全
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="java script"> js脚本开始;
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
window.open(′url′,′窗口名′,′属性列表′);
〈/script〉
其中“url”是在窗口中显示的html文档的地址;“窗口名”可任意起一个,但不要用中文;“属性列表”是一个用逗号分开的各个属性值的字符串,它确定了弹出窗口的外观与状态。常用属性有:
toolbar(是否显示工具栏
将下面这段代码插入你的页面中,在页面加载时就会自动弹出一个窗口,并打开Google搜索引擎,是不是很简单啊!
将代码放置在〈!?XXX --〉中间是为了兼容较低版本浏览器的需要,在低版本的浏览器中标签内的内容将被视作注视。
打开的页面使用绝对路径(http://)或相对路径(../page.htm)都可以。
-->
</script>
然后,在相同目录下新建一个popup.htm网页(注意要与上面的url对应!),用于显示在弹出窗口中。在新建文件的源代码中加入如下代码:
代码:
<script language="java script">
function closeit() {
setTimeout("self.close()",10000)
js实现浮动窗口(广告)
1.<!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=UTF-8"> <title>Insert title here</title></head><script type="text/javascript"src=jquery.js></script><script type="text/javascript"src="js/staticObj_js.js"></script><script type="text/javascript"src="js/moveObj_js.js"></script><script type="text/javascript"src="js/test_js.js"></script><style type="text/css">body {background-image: url("/TstA/resources/beijing.jpg");}</style><body onload="main()"onresize="windowSizeChanged()"><div id="divAdv"style="position:absolute;left:20px;top:80px;width:180px;height:1040p x;"></div></body></html>2.var sObj = null;var mObj = null;function main(){sObj = new StaticObj(7, -2);sObj.run();mObj = new MoveObj();}function windowSizeChanged(){sObj.resizeEvent();}function move(){var top= document.body.scrollTop;sObj.imageObj.css({"top": top + 100 });mObj.imageObj.css({"top": top + 100 });}window.onscroll=move;3.var StaticObj = function(speed, accelerate){this.posX = 0;this.posY = 100;this.rangeX = $(window).width() - 128;this.sp = parseFloat(speed);this.acc = parseFloat(accelerate);this.imageObj = $("<img />");this.imageObj.css("position", "absolute");this.imageObj.css("width", "126px");this.imageObj.css("height", "270px");this.imageObj.attr({"src" : "resources/img2.png"});this.imageObj.appendTo("body");this.imageObj.css({"left": this.posX, "top": this.posY}); };StaticObj.prototype.move = function(){if(this.posX < this.rangeX){if(this.posX >= (this.rangeX * 0.66)){this.sp = 2;}this.posX += this.sp;if(this.posX > this.rangeX)this.posX = this.rangeX;}else{this.posX = this.rangeX;}this.imageObj.css({"left": this.posX});};StaticObj.prototype.run = function(){var temp = this;setInterval(function(){temp.move();}, 5);};StaticObj.prototype.resizeEvent = function(){ this.rangeX = $(window).width() - 128;};4.var MoveObj = function(){this.imageObj = $("<img />");this.imageObj.css("position", "absolute");this.imageObj.css("width", "122px");this.imageObj.css("height", "269px");this.imageObj.attr({"src" : "resources/img1.png"});this.imageObj.appendTo("body");this.imageObj.css({"left": "0px", "top": "100px" }); };5.Beijing.jpg。
网站JS浮动广告代码
网站Js浮动广告代码//JS代码:var delta=0.08var 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)+'">'+cont ent+'</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.itemssetInterval('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)) {vardx=(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)) {vardy=(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();//右侧浮动广告代码(QQ对话栏):theFloaters.addItem('followDiv1','document.body.clientWidth-140',195,'<a target="_blank" href="/msgrd?v=3&uin=2357484552&site=qq&menu=yes"><img border="0" src="/pa?p=2:2357484552:53" alt="give me message" title="click here"></a>');//左侧浮动广告代码(可调用flash或图片):theFloaters.addItem('followDiv2',6,80,'<EMBED src="..." quality=high WIDTH=100 HEIGHT=300 TYPE=application/x-shockwave-flash id=ad wmode=opaque></EMBED>');theFloaters.play();//广告图片的调用方法://<a href=/lanren/ target=_blank><img src=images/ad_100x300.jpg border=0></a>。
悬浮广告代码-js手机端网站底部和头部悬浮html广告代码教程【附实例】
悬浮⼴告代码-js⼿机端⽹站底部和头部悬浮html⼴告代码教程【附实例】<script>document.write("<style>");document.write("#topNavad{background-color:#fff0; z-index:999; position:fixed; top:0; left:0; width:100%; _position:absolute;");document.write("_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); overflow:visible; }");document.write("#bottomNavad{background-color:#fff0; z-index:999; position:fixed; bottom:0; left:0; width:100%; _position:absolute;");document.write("_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); overflow:visible; }");document.write("<\/style>");document.write("");document.write(" ");document.write("<!--头部-->");document.write("<div id=\"topNavad\">");document.write("<div id=\"MyDiv2\">");document.write("<div id=\"newsImg\">");document.write("<center>");document.write("<a href=\"https:\/\/\" rel=\"nofollow\" target=\"_blank\">");document.write("<img src=\"shunwang.jpg\" title=\"AD\" \/ style=\"width:100%\">");document.write("<\/a>");document.write("<\/center>");document.write("<\/div>");document.write("<span onclick='CloseDiv(\"MyDiv2\")' style=\"text-align:right; display:block;\">关闭<\/span>");document.write("");document.write("<\/div>");document.write("<\/div>");document.write("<!--头部end-->");document.write("");document.write("<!--底部-->");document.write("<div id=\"bottomNavad\">");document.write("<div id=\"MyDiv1\">");document.write("<span onclick='CloseDiv(\"MyDiv1\")' style=\"text-align:right; display:block;\">关闭<\/span>");document.write("<center>");document.write("<a href=\"https:\/\/\" rel=\"nofollow\" target=\"_blank\">");document.write("<img src=\"shunwang.jpg\" title=\"AD\" \/ style=\"width:100%\">");document.write("<\/a>");document.write("<\/center>");document.write("<\/div>");document.write("<\/div>");document.write("<!--底部end-->");document.write("");function CloseDiv(div) {document.getElementById(div).style.display = 'none';};</script>悬浮⼴告代码-js⼿机端⽹站底部和头部悬浮html⼴告代码教程-移动端的悬浮⼴告代码html版本:<style>#topNavad{background-color:#fff0; z-index:999; position:fixed; top:0; left:0; width:100%; _position:absolute;_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); overflow:visible; }#bottomNavad{background-color:#fff0; z-index:999; position:fixed; bottom:0; left:0; width:100%; _position:absolute;_top: expression(documentElement.scrollTop + documentElement.clientHeight-this.offsetHeight); overflow:visible; }</style><!--头部--><div id="topNavad"><div id="MyDiv2"><div id="newsImg"><center><a href="https://" rel="nofollow" target="_blank"><img src="shunwang.jpg" title="AD" / style="width:100%"></a></center></div><span onclick='CloseDiv("MyDiv2")' style="text-align:right; display:block;">关闭</span></div></div><!--头部end--><!--底部--><div id="bottomNavad"><div id="MyDiv1"><span onclick='CloseDiv("MyDiv1")' style="text-align:right; display:block;">关闭</span> <center><a href="https://" rel="nofollow" target="_blank"><img src="shunwang.jpg" title="AD" / style="width:100%"></a></center></div></div><!--底部end--><script>function CloseDiv(div) {document.getElementById(div).style.display = 'none';};</script>。
超简单无缝滚动漂浮广告代码属性
超简单⽆缝滚动漂浮⼴告代码属性实现功能:1、⽆缝滚动(左右上下)2、漂浮⼴告(包括在屏幕漂浮⼏次消失)两个事件onmouseover="this.stop()" ⿏标划过停⽌滚动onmouseout="this.start()" ⿏标离开继续滚动<marquee width="920" onmouseover="this.stop()" onmouseout="this.start()" scrollamount="20" behavior="scroll" align="absbottom"> @foreach (var item in Model.NewsItems_WebNotice){<u><a href="@Url.RouteUrl("NewsItem", new { SeName = item.SeName })">@Html.StrTruncation(item.Title, 10)</a></u>}</marquee>Marquee 属性列表:align设定<marquee>标签内容的对齐⽅式absbottom:绝对底部对齐(与g、p等字母的最下端对齐)absmiddle:绝对中央对齐baseline:底线对齐bottom:底部对齐(默认)left:左对齐middle:中间对齐right:右对齐texttop:顶线对齐top:顶部对齐behavior设定滚动的⽅式:alternate:表⽰在两端之间来回滚动。
scroll:表⽰由⼀端滚动到另⼀端,会重复。
slide:表⽰由⼀端滚动到另⼀端,不会重复scrollamount="5":设置滚动的速度direction设定活动字幕的滚动⽅向代码如下:<marquee direction="down">设定活动字幕的滚动⽅向direction="down":向下</marquee><marquee direction="left">设定活动字幕的滚动⽅向direction="left":向左</marquee><marquee direction="right">设定活动字幕的滚动⽅向direction="right":向右</marquee><marquee direction="up">设定活动字幕的滚动⽅向direction="up":向上</marquee>hspace设定活动字幕⾥所在的位置距离⽗容器⽔平边框的距离This controls the horizontal(⽔平)space around thedisplay box.代码如下:<table width="500"border="1" align="center" cellpadding="0"cellspacing="0"><tr><td><marquee hspace="100"bgcolor="#CCCCCC">hspace="100"</marquee></td></tr></table>loop设定滚动的次数,当loop=-1表⽰⼀直滚动下去,默认为-1Marquee标记⽤于在可⽤浏览区域中滚动⽂本。
兼容性非常好的js右下角与漂浮广告代码
兼容性⾮常好的js右下⾓与漂浮⼴告代码兼容ie6 7 8 ,ff3.5 3.6,chrome 4.1.2,safari重新修正1.滚动时抖动的问题,主要体现在ff3.6上2.加⼊了ie6下的固定3.分成了两个块,xhtml,html解析4.随着屏幕⼤⼩⽽变动兼容ie6 7 8ff3.5 3.6chrome 4.1.2safari"/TR/xhequiv="Content-Type"/> <title>Untitled Document</title> <style> html,body{ padding:0; margin:0; } </style> <div id="aa"style="width:100px;heigh t:100px;background:#c0c 0c0;">我在随平滚</div> <div id="bb"style="width:100px;heigh t:100px;background:#c0c 0c0;">我静⽌不动</div> <divstyle="width:100%;height :1500px;background:#00 0"></div> <div:1500px;background:gre en"></div> <div:1500px;background:red" ></div> <script> function scrollx(p){ var d = document,dd =d.documentElement,db = d.body,w = window,o =d.getElementById(p.id),ie6 = /msie6/i.test(erAg ent),style,timer; if(o){o.style.cssText+=";position:"+(p.f&&!ie6?'fixed':'absolut e')+";"+(p.l==undefined?'right:0;':全选注:引⼊外部Js需再刷新⼀下页⾯才能执⾏]<metacontent="text/html;charset=utf-8" http-equiv="Content-Type"/><title>UntitledDocument</title> <style>html,body{ padding:0;margin:0; } </style> <divid="aa"style="width:100px;height:100px;background:#c0c0c0;">我在随平滚</div><div id="bb"style="width:100px;height:100px;background:#c0c0c0;">我静⽌不动</div><divstyle="width:100%;height:1500px;background:#000"></div> <divstyle="width:100%;height:1500px;background:green"></div> <divstyle="width:100%;height:1500px;background:red"></div> <script> functionscroll(p){ var d =document,dd =d.documentElement,db =d.body,w = window,o =d.getElementById(p.id),ie=/msie/i.test(erAgent),style,timer; if(o){//ie8下position:fixed下topleft失效 o.style.cssText全选注:引⼊外部Js需再刷新⼀下页⾯才能执⾏]。
js浮动广告代码示例
<!--<div id="ad" style="position:absolute"><a href= target="_blank"><img src="flot3.gif" border="0"></a></div>
<script>
var x = 50,y = 60 //浮动层的初始位置,分别对应层的初始X坐标和Y坐标
var xin = true, yin = true //判断层的X坐标和Y坐标是否在在控制范围之内,xin为真是层向右移动,否则向左;yin为真是层向下移动,否则向上
var step = 1 //层移动的步长,值越大移动速度越快
obj.style.top = y + document.body.scrollTop //更新层的Y坐标,实现Y轴方向上的运动;document.body.scrollTop为文档区域的滚动条向下拉的距离,以保证在滚动条下拉时层仍在可见范围内
x = x + step*(xin?1:-1) //通过判断层的范围决定层在X轴上的运动方向
if (y > B) { yin = false; y = B } //层超出下边界时的处理
}
var itl= setInterval("floatAD()", delay) //每delay秒执行一次floatAD函数
obj.onmouseover=function(){clearInterval(itl)} //层在鼠标移上时清除上面的间隔事件,实现层在的鼠标移上时停止运动的效果
JS实现悬浮移动窗口(悬浮广告)的特效
JS实现悬浮移动窗⼝(悬浮⼴告)的特效js⽅法:复制代码代码如下:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><title> New Document </title><meta name="Generator" content="EditPlus"><meta name="Author" content=""><meta name="Keywords" content=""><meta name="Description" content=""><script type="text/javascript">window.onload=function(){//写⼊var oneInner = document.createElement("div");oneInner.setAttribute("style","background:#663398;position:absolute;width:100px;height:100px;border:solid 3px #2F74A7;cursor:pointer;");var oneButton = document.createElement("input");oneButton.setAttribute("type","button");oneButton.setAttribute("value","x");if (oneButton.style.cssFloat){oneButton.style.cssFloat="right"}else{oneButton.style.styleFloat="right"}oneInner.appendChild(oneButton);document.body.appendChild(oneInner);//定时器var a1a = setInterval(moves,100);//函数var x = 10;var y = 10;function moves(){var tops = oneInner.offsetTopvar lefts = oneInner.offsetLeftif (lefts>=document.documentElement.clientWidth-oneInner.offsetWidth||lefts<=0){x=-x}if (tops>=document.documentElement.clientHeight-oneInner.offsetHeight||tops<=0){y=-y}tops+=y;lefts+=x;oneInner.style.top=tops+"px"oneInner.style.left=lefts+"px"}//悬停停⽌oneInner.onmouseover=function(){clearInterval(a1a);}//放⼿继续运动oneInner.onmouseout=function(){a1a =setInterval(moves,100);}//删除oneButton.onclick=function(){document.body.removeChild(oneInner);}}</script></head><body></body></html>jquery⽅法:复制代码代码如下:<!DOCTYPE html><html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script type="text/javascript" src="https:///workspace/js/jquery-1.7.min.js"></script><script>$(function(){//写⼊div$("<div/>",{id:"moveWindow"}).css({width:"200px",height:"200px",border:"solid 3px#2F74A7",background:"#663398",position:"absolute",cursor:"pointer"}).appendTo("body");//写⼊关闭按钮$("<div/>",{id:"removeMW"}).css({width:"20px",height:"20px",background:"red",float:"right"}).appendTo("#moveWindow"); //定时器var move = setInterval(moves,100);var x= 10;var y= 10;function moves (){var mw = $("#moveWindow").offset();var lefts =mw.left;var tops = mw.top;if (lefts>=$(window).width()-$("#moveWindow").width()||lefts<=0){x=-x}if (tops>=$(window).height()-$("#moveWindow").height()||tops<=0){y=-y}lefts+=x;tops+=y;$("#moveWindow").offset({top:tops,left:lefts});}//悬停停⽌运动$("#moveWindow").mouseover(function(){clearInterval(move);});//移开⿏标后继续运动$("#moveWindow").mouseout(function(){move = setInterval(moves,100);});//点击按钮关闭$("#removeMW").click(function(){$("#moveWindow").remove();});})</script></head><body></body></html>基本思路:1.页⾯加载完成之后向页⾯插⼊窗⼝,之后向窗⼝插⼊关闭按钮2.使⽤setInterval()函数触发moves()函数开始动画3.moves函数:⾸先获取当前窗⼝位置,之后随时间使窗⼝位移,每当位移到游览器边缘时反向运动4.添加其他事件:⿏标悬停停⽌运动,⿏标离开继续运动,点击按钮关闭窗⼝ps:不建议使⽤这个特效,影响⽤户体验希望对你有所帮助!^_^!~~。
浮动广告代码
注:浮动广告代码:<SCRIPT language=JavaScript>self.onError=null;currentX = currentY = 0;whichIt = null;lastScrollX = 0; lastScrollY = 0;NS = (yers) ? 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.sohususpend.style.pixelTop += percent;if(NS) document.sohususpend.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.sohususpend.style.pixelLeft += percent;if(NS) document.sohususpend.left += percent;lastScrollX = lastScrollX + percent;}}function checkFocus(x,y) {stalkerx = document.sohususpend.pageX;stalkery = document.sohususpend.pageY;stalkerwidth = document.sohususpend.clip.width;stalkerheight = document.sohususpend.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("sohususpend") == -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.MOUSEDOWN);if(checkFocus (e.pageX,e.pageY)) {whichIt = document.sohususpend;StalkerTouchedX = e.pageX-document.sohususpend.pageX;StalkerTouchedY = e.pageY-document.sohususpend.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.MOUSEDOWN);return true;}if(NS) {window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN); window.onmousedown = grabIt;window.onmousemove = moveIt;window.onmouseup = dropIt;}if(IE) {document.onmousedown = grabIt;document.onmousemove = moveIt;document.onmouseup = dropIt;}if(NS || IE) action = window.setInterval("heartBeat()",1);</SCRIPT>。
传媒.用JavaScript做的漂浮的广告(传媒)
<DIVid=imgstyle="Z-INDEX:1000;POSITION:absolute" onMouseOver="stop()"onMouseOut="www_helpor_net()"><TABLEcellSpacing=0cellPadding=0border=0><TR><TDalign="right"><Astyle="CURSOR:hand"onclick=closepiao()><b>关闭</b></A> </TD></TR><TR><TDid='obja'><ahref="/"><IMGid=objsrc="images/"border=0></a></TD></TR></TABLE></DIV><%--悬浮窗口结束--%><%--悬浮窗口开始--%><SCRIPTlanguage=JavaScript>varxPos=20;varyPos=.clientHeight;varstep=2;vardelay=60;varheight=0; varHoffset=0; varWoffset=0; varyon=0;varxon=0; varpause=true; varinterval;.top=yPos; functionchangePos(){ width=.clientWidth; height=.clientHeight; Hoffset=;Woffset=;.left=xPos+.scrollLeft; .top=yPos+.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);}}functionclosepiao(){("img").="none";}functionstop(){clearInterval(interval);}functionwww_helpor_net(){//closepiao();//注释后显示飘="visible";interval=setInterval('changePos()',delay); }www_helpor_net();</SCRIPT>。
Javascript实现带关闭按钮的网页漂浮广告代码
Javascript实现带关闭按钮的⽹页漂浮⼴告代码复制代码代码如下:<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>带关闭按钮的⽹页漂浮⼴告代码</title></head><body><div id="img" style="position: absolute; left: 311; top: 815;visibility :hidden;" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="right"><a href="#" target="_blank"><img border="0" src="图⽚路径" onload="return imgzoom(this,600);"onclick="javascript:window.open(this.src);" style="cursor:pointer;"/></a><span style="CURSOR:hand;color:red;font-weight:bold" onclick="clearInterval(interval);img.style.visibility ='hidden'">X</span></div><script language=javascript src=ff.js></script></body></html>ff.js代码复制代码代码如下:var xPos = 20;var yPos = document.body.clientHeight;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;img.style.top = yPos;function changePos() {width = document.body.clientWidth;height = document.body.clientHeight;Hoffset = img.offsetHeight;Woffset = img.offsetWidth;img.style.left = xPos + document.body.scrollLeft;img.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() {img.style.visibility = "visible";interval = setInterval('changePos()', delay); }start();。
js实现左右两侧浮动广告
js实现左右两侧浮动⼴告本⽂实例为⼤家分享了js实现左右浮动⼴告展⽰的具体代码,供⼤家参考,具体内容如下<html><title>左右两侧浮动⼴告</title><head></head><body><table style="background-color:#EEEEE2;width:1024px;height:2000px;t" align="center"><tr><td> </td></tr></table><SCRIPT LANGUAGE="JavaScript"><!--var showad = true;var Toppx = 60; //上端位置var AdDivW = 100; //宽度var AdDivH = 300; //⾼度var PageWidth = 800; //页⾯多少宽度象素下正好不出现左右滚动条var MinScreenW = 1024; //显⽰⼴告的最⼩屏幕宽度象素var ClosebuttonHtml = '<div align="right" style="position: absolute;top:0px;right:0px;margin:2px;padding:2px;z-index:2000;"><a href="javascript:;" rel="external nofollow" rel="external nofollow" mce_href="javascript:;" rel="external nofollow" rel="external nofollo var AdContentHtml = '<div align="center" style="color:green;font-size:23pt;font-family:⿊体;" mce_style="color:green;font-size:23pt;font-family:⿊体;"><br><br>⼴告</div>';document.write('<div id="Javascript.LeftDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ ClosebuttonHtml+ '<div>'+ AdContentHtml+ '</div></div>');document.write('<div id="Javascript.RightDiv" style="position: absolute;border: 1px solid #336699;background-color:#EEEEE2;z-index:1000;width:'+AdDivW+'px;height:'+AdDivH+'px;top:-1000px;word-break:break-all;display:none;">'+ ClosebuttonHtml+ '<div>'+ AdContentHtml+ '</div></div>');function scall() {if (!showad) {return;}if (document.body.clientWidth < MinScreenW) {//alert("临时提⽰:/n/n显⽰器分辨率宽度⼩于" + MinScreenW + ",不显⽰⼴告");showad = false;document.getElementById("Javascript.LeftDiv").style.display = "none";document.getElementById("Javascript.RightDiv").style.display = "none";return;}var Borderpx =( ((window.screen.width - PageWidth) / 2 - AdDivW) / 2 );document.getElementById("Javascript.LeftDiv").style.display = "";document.getElementById("Javascript.LeftDiv").style.top = document.body.scrollTop+ Toppx;document.getElementById("Javascript.LeftDiv").style.left = document.body.scrollLeft+ Borderpx;document.getElementById("Javascript.RightDiv").style.display = "";document.getElementById("Javascript.RightDiv").style.top = document.body.scrollTop+ Toppx;document.getElementById("Javascript.RightDiv").style.left = document.body.scrollLeft+ document.body.clientWidth- document.getElementById("Javascript.RightDiv").offsetWidth- Borderpx;}function hidead() {showad = false;document.getElementById("Javascript.LeftDiv").style.display = "none";document.getElementById("Javascript.RightDiv").style.display = "none";}window.onscroll = scall;window.onresize = scall;window.onload = scall;//--></SCRIPT></body></html>以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。
JS右下角广告窗口代码(可收缩、展开及关闭)
JS右下⾓⼴告窗⼝代码(可收缩、展开及关闭)本⽂实例讲述了JS右下⾓⼴告窗⼝代码。
分享给⼤家供⼤家参考。
具体如下:这是⼀款右下⾓窗⼝JS代码,完美的右下⾓,仿新浪博客的右个⾓弹出窗⼝,这款Javascript代码在兼容性和操作舒适度⽅⾯做的相当不错。
调⽤了⼏张外部的图⽚,使⽤时⾃⾏下载吧。
运⾏效果截图如下:在线演⽰地址如下:具体代码如下:<!DOCTYPE html PUBLIC "-//W3C//h2D XHTML 1.0 Transitional//EN""/TR/xhtml1/h2D/xhtml1-transitional.h2d"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style>* { padding: 0; margin: 0; }li { list-style: none; }body { background: #eee; }.float_layer { width: 300px; border: 1px solid #aaaaaa; display:none; background: #fff; }.float_layer h2 { height: 25px; line-height: 25px; padding-left: 10px; font-size: 14px; color: #333; background: url(images/title_bg.gif) repeat-x; border-bottom: 1px solid #aaaaaa; position: relative; }.float_layer .min { width: 21px; height: 20px; background: url(images/min.gif) no-repeat 0 bottom; position: absolute; top: 2px; right: 25px; }.float_layer .min:hover { background: url(images/min.gif) no-repeat 0 0; }.float_layer .max { width: 21px; height: 20px; background: url(images/max.gif) no-repeat 0 bottom; position: absolute; top: 2px; right: 25px; }.float_layer .max:hover { background: url(images/max.gif) no-repeat 0 0; }.float_layer .close { width: 21px; height: 20px; background: url(images/close.gif) no-repeat 0 bottom; position: absolute; top: 2px; right: 3px; }.float_layer .close:hover { background: url(images/close.gif) no-repeat 0 0; }.float_layer .content { height: 160px; overflow: hidden; font-size: 14px; line-height: 18px; color: #666; text-indent: 28px; }.float_layer .wrap { padding: 10px; }</style><script type="text/javascript">function miaovAddEvent(oEle, sEventName, fnHandler){if(oEle.attachEvent){oEle.attachEvent('on'+sEventName, fnHandler);}else{oEle.addEventListener(sEventName, fnHandler, false);}}window.onload = function(){var oDiv=document.getElementById('miaov_float_layer');var oBtnMin=document.getElementById('btn_min');var oBtnClose=document.getElementById('btn_close');var oDivContent=oDiv.getElementsByTagName('div')[0];var iMaxHeight=0;var isIE6=erAgent.match(/MSIE 6/ig) && !erAgent.match(/MSIE 7|8/ig);oDiv.style.display='block';iMaxHeight=oDivContent.offsetHeight;if(isIE6){oDiv.style.position='absolute';repositionAbsolute();miaovAddEvent(window, 'scroll', repositionAbsolute);miaovAddEvent(window, 'resize', repositionAbsolute);}else{oDiv.style.position='fixed';repositionFixed();miaovAddEvent(window, 'resize', repositionFixed);}oBtnMin.timer=null;oBtnMin.isMax=true;oBtnMin.onclick=function (){startMove(oDivContent, (this.isMax=!this.isMax)?iMaxHeight:0,function (){oBtnMin.className=oBtnMin.className=='min'?'max':'min';});};oBtnClose.onclick=function (){oDiv.style.display='none';};};function startMove(obj, iTarget, fnCallBackEnd){if(obj.timer){clearInterval(obj.timer);}obj.timer=setInterval(function (){doMove(obj, iTarget, fnCallBackEnd);},30);}function doMove(obj, iTarget, fnCallBackEnd){var iSpeed=(iTarget-obj.offsetHeight)/8;if(obj.offsetHeight==iTarget){clearInterval(obj.timer);obj.timer=null;if(fnCallBackEnd){fnCallBackEnd();}}else{iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);obj.style.height=obj.offsetHeight+iSpeed+'px';((erAgent.match(/MSIE 6/ig) && erAgent.match(/MSIE 6/ig).length==2)?repositionAbsolute:repositionFixed)()}}function repositionAbsolute(){var oDiv=document.getElementById('miaov_float_layer');var left=document.body.scrollLeft||document.documentElement.scrollLeft;var top=document.body.scrollTop||document.documentElement.scrollTop;var width=document.documentElement.clientWidth;var height=document.documentElement.clientHeight;oDiv.style.left=left+width-oDiv.offsetWidth+'px';oDiv.style.top=top+height-oDiv.offsetHeight+'px';}function repositionFixed(){var oDiv=document.getElementById('miaov_float_layer');var width=document.documentElement.clientWidth;var height=document.documentElement.clientHeight;oDiv.style.left=width-oDiv.offsetWidth+'px';oDiv.style.top=height-oDiv.offsetHeight+'px';}</script></head><body style="height: 2200px"><div class="float_layer" id="miaov_float_layer"><h2><strong>这是标题</strong><a id="btn_min" href="javascript:;" class="min"></a><a id="btn_close" href="javascript:;" class="close"></a></h2><div class="content"><div class="wrap">这⾥放置的是⼴告信息,你可以填⼊任何的⼴告内容,⽐如像这样:<strong>是国内专业的⽹站建设资源、脚本编程学习类⽹站,提供asp、php、、javascript、jquery、vbscript、dos批处理、⽹页制作、⽹络编程、⽹站建设等编程资料</strong>脚本特效下 </div></div></div></body></html>希望本⽂所述对⼤家的javascript程序设计有所帮助。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
obj.onmouseover=function(){clearInterval(interval);}
obj.onmouseout=function(){interval=setInterval(obj.CustomMethod, delay);}
}
}
***** content ******
</div>
var ad=new AdMove("Div2");
ad.Run();
*/
////////////////////////////////////////////////////////
var AdMoveConfig=new Object();
xScroll = document.documentElement.scrollLeft;
} else if (document.body) {
xScroll = document.body.scrollLeft;
}
if (self.pageYOffset) {
yScroll = self.pageYOffset;
}
var obj=document.getElementById(id);
obj.style.position="absolute";
var W=AdMoveConfig.MoveWidth-obj.offsetWidth;
var H=AdMoveConfig.MoveHeight-obj.offsetHeight;
} else if (document.documentElement && document.documentElement.scrollTop){
yScroll = document.documentElement.scrollTop;
} else if (document.body) {
} else {
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) {
} else if (document.body.scrollHeight > document.body.offsetHeight){
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
if (x > W){dirx = -1;x = W;kx=Math.sin(rad);ky=Math.cos(rad);}
y = y + step*ky*diry;
if (y < 0){diry = 1;y = 0;kx=Math.sin(rad);ky=Math.cos(rad);}
var x = W*Math.random(),y = H*Math.random();
ar 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 winsize=GetPageSize();
AdMoveConfig.MoveWidth=winsize[2];
AdMoveConfig.MoveHeight=winsize[3];
AdMoveConfig.Scroll();
}
AdMoveConfig.Scroll=function(){
addEvent(window,"scroll",AdMoveConfig.Scroll);
function AdMove(id){
if(!AdMoveConfig.IsInitialized){
AdMoveConfig.Resize();
AdMoveConfig.IsInitialized=true;
}
}else{
return false;
}
}
function getPageScroll(){
var xScroll,yScroll;
if (self.pageXOffset) {
xScroll = self.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollLeft){
AdMoveConfig.IsInitialized=false;
AdMoveConfig.ScrollX=0;
AdMoveConfig.ScrollY=0;
AdMoveConfig.MoveWidth=0;
AdMoveConfig.MoveHeight=0;
AdMoveConfig.Resize=function(){
} else {
pageHeight = yScroll;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
yScroll = document.body.scrollTop;
}
arrayPageScroll = new Array(xScroll,yScroll);
return arrayPageScroll;
}
function GetPageSize(){
var xScroll, yScroll;
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {
//-->
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
//广告脚本文件 AdMove.js
/*
例子
<div id="Div2">
if (y > H){diry = -1;y = H;kx=Math.sin(rad);ky=Math.cos(rad);}
}
this.Run=function(){
var delay = 10;
interval=setInterval(obj.CustomMethod,delay);
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 = x + step*kx*dirx;
if (x < 0){dirx = 1;x = 0;kx=Math.sin(rad);ky=Math.cos(rad);}
var winscroll=getPageScroll();
AdMoveConfig.ScrollX=winscroll[0];
AdMoveConfig.ScrollY=winscroll[1];
}
addEvent(window,"resize",AdMoveConfig.Resize);
var step = 1;
var interval;
this.SetLocation=function(vx,vy){x=vx;y=vy;}
this.SetDirection=function(vx,vy){dirx=vx;diry=vy;}
obj.CustomMethod=function(){
<!--
//公共脚本文件 main.js
function addEvent(obj,evtType,func,cap){
cap=cap||false;
if(obj.addEventListener){
obj.addEventListener(evtType,func,cap);
windowWidth = document.body.clientWidth;