41)JS运动之右侧跟随悬浮固定窗口中间悬浮框(对联悬浮框

网页设计教程与开发
提供各种常见网页效果
提供各种各样的设计教程
装扮QQ,让QQ变得更酷
设计参考,提高自升水平
学习服务器和操作系统
提供各种素材和工具
收藏学习资料
您现在的位置:&&>>&&>>&&>>&&>>&正文
js 左右悬浮对联广告特效代码
js制作web网页左右悬浮广告特效。
&script src="js/ad.js" type="text/javascript"&&/script&
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" lang="zh-CN"&
&meta http-equiv="Content-Type" content="text/ charset=utf-8" /&
&title&js制作web网页左右悬浮广告特效_&/title&
body{font-family:Arial, Helvetica, sans-serif,"宋体"; font-size:12 height:2000 color:#667382}
*{ padding:0 margin:0}
ul{margin:0padding:0}
li{list-style-type:margin:0padding:0}
.fl{ float:}
.fr{ float:}
.cl{ clear:}
.zz {margin-top: 0margin-right:margin-bottom: 0
margin-left:}
.tc{ text-align:}
.jiac{ font-weight:}
.cur{cursor:}
img{ border:0}
&script src="js/ad.js" type="text/javascript"&&/script&
3、js悬浮广告代码 ad.js
var browser={ie6:function(){return((window.XMLHttpRequest==undefined)&&(ActiveXObject!=undefined))},getWindow:function(){var myHeight=0;var myWidth=0;if(typeof(window.innerWidth)=='number'){myHeight=window.innerHmyWidth=window.innerWidth}else if(document.documentElement){myHeight=document.documentElement.clientHmyWidth=document.documentElement.clientWidth}else if(document.body){myHeight=document.body.clientHmyWidth=document.body.clientWidth}return{'height':myHeight,'width':myWidth}},getScroll:function(){var myHeight=0;var myWidth=0;if(typeof(window.pageYOffset)=='number'){myHeight=window.pageYOmyWidth=window.pageXOffset}else if(document.documentElement){myHeight=document.documentElement.scrollTmyWidth=document.documentElement.scrollLeft}else if(document.body){myHeight=document.body.scrollTmyWidth=document.body.scrollLeft}return{'height':myHeight,'width':myWidth}},getDocWidth:function(D){if(!D)var D=return Math.max(Math.max(D.body.scrollWidth,D.documentElement.scrollWidth),Math.max(D.body.offsetWidth,D.documentElement.offsetWidth),Math.max(D.body.clientWidth,D.documentElement.clientWidth))},getDocHeight:function(D){if(!D)var D=return Math.max(Math.max(D.body.scrollHeight,D.documentElement.scrollHeight),Math.max(D.body.offsetHeight,D.documentElement.offsetHeight),Math.max(D.body.clientHeight,D.documentElement.clientHeight))}};var dom={ID:function(id){var type=typeof(id);if(type=='object')if(type=='string')return document.getElementById(id);return null},insertHtml:function(html){var frag=document.createDocumentFragment();var div=document.createElement("div");div.innerHTML=for(var i=0,ii=div.childNodes.i&i++){frag.appendChild(div.childNodes[i])}document.body.insertBefore(frag,document.body.firstChild)}};var myEvent={add:function(element,type,handler){var ele=dom.ID(element);if(!ele)if(ele.addEventListener)ele.addEventListener(type,handler,false);else if(ele.attachEvent)ele.attachEvent("on"+type,handler);else ele["on"+type]=handler},remove:function(element,type,handler){var ele=dom.ID(element);if(!ele)if(ele.removeEventListener)ele.removeEventListener(type,handler,false);else if(ele.detachEvent)ele.detachEvent("on"+type,handler);else ele["on"+type]=null}};var position={rightCenter:function(id){var id=dom.ID(id);var ie6=browser.ie6();var win=browser.getWindow();var ele={'height':id.clientHeight,'width':id.clientWidth};if(ie6){var scrollBar=browser.getScroll()}else{var scrollBar={'height':0,'width':0};id.style.position='fixed'}ele.top=parseInt((win.height-ele.height)/2+scrollBar.height);id.style.top=ele.top+'px';id.style.right='3px'},floatRightCenter:function(id){position.rightCenter(id);var fun=function(){position.rightCenter(id)};if(browser.ie6()){myEvent.add(window,'scroll',fun);myEvent.add(window,'resize',fun)}else{myEvent.add(window,'resize',fun)}},leftCenter:function(id){var id=dom.ID(id);var ie6=browser.ie6();var win=browser.getWindow();var ele={'height':id.clientHeight,'width':id.clientWidth};if(ie6){var scrollBar=browser.getScroll()}else{var scrollBar={'height':0,'width':0};id.style.position='fixed'}ele.top=parseInt((win.height-ele.height)/2+scrollBar.height);id.style.top=ele.top+'px';id.style.left='3px'},floatLeftCenter:function(id){position.leftCenter(id);var fun=function(){position.leftCenter(id)};if(browser.ie6()){myEvent.add(window,'scroll',fun);myEvent.add(window,'resize',fun)}else{myEvent.add(window,'resize',fun)}}};
function ad_left(){
html = '&div id="ad_left" style="position:width:130height:300z-index:10001"&&a style="position:top:-15left:0;" href="javascript:void(0);" onclick="document.getElementById(\'ad_left\').style.display=\'none\'"&关闭&/a&&a href="http://www.plchome.org"&&img src="images/ad.jpg" width="130" height="300" /&&/a&&/div&';
dom.insertHtml(html);position.floatLeftCenter('ad_left');
function ad_right(){
html = '&div id="ad_right" style="position:width:130height:300z-index:10001"&&a style="position:top:-15right:0;" href="javascript:void(0);" onclick="document.getElementById(\'ad_right\').style.display=\'none\'"&关闭&/a&&a href=""&&img src="images/ad.jpg" width="130" height="300" /&&/a&&/div&';
dom.insertHtml(html);position.floatRightCenter('ad_right');
myEvent.add(window,'load',ad_left);
myEvent.add(window,'load',ad_right);
转载请注明:破洛洛(谢谢合作)
上一篇文章: 下一篇文章:
网友评论:
[][][][][][][][][][]js 左右悬浮对联广告代码示例-学网-中国IT综合门户网站-提供健康,养生,留学,移民,创业,汽车等信息
js 左右悬浮对联广告代码示例
来源:互联网 更新时间: 12:12:53 责任编辑:鲁晓倩字体:
一段js 左右悬浮广告代码,只要修改广告图片地址与连接地址,相应参数根据页面调整下就可以使用这段左右悬浮广告代码了
var delta=0.15
function floaters() {
this.items = ;
this.addItem = function(id,x,y,content)
document.write('&DIV id='+id+' style="Z-INDEX: 10; POSITION: width:80 height:60left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'"&'+content+'&/DIV&');
var newItem
newItem.object
= document.getElementById(id);
this.items[this.items.length] = newI
this.play = function()
collection
= this.items
setInterval('play()',10);
function play()
for(var i=0;i&collection.i++)
var followObj = collection[i].
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)*
dx=(dx&0?1:-1)*Math.ceil(Math.abs(dx));
followObj.style.left=followObj.offsetLeft+
if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*
dy=(dy&0?1:-1)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+
followObj.style.display = '';
var theFloaters = new floaters();
theFloaters.addItem('followDiv1','document.body.clientWidth-112',230,'&a href=左链接地址 target=_blank&&img src=左图片地址 border=0&&/a&');
theFloaters.addItem('followDiv2',12,230,'&a href=右链接地址 target=_blank&&img src=右图片地址 border=0&&/a&');
theFloaters.play();
另存为*.js文件,在页面中引用:&script src="*.js"&&/script&调用即可,*代表你另存的文件名!
注意:修改广告图片地址和连接地址!相应的参数可以根据页面自行调整。
相关文章:
上一篇文章:下一篇文章:
最新添加资讯
24小时热门资讯
Copyright © 2004- All Rights Reserved. 学网 版权所有
京ICP备号-1 京公网安备02号未注册过用户可以点击直接登录哦!
使用注册邮箱登录
选择画板...
你已经成功采集到
&|关闭窗口}

我要回帖

更多关于 网站右侧悬浮代码 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信