javascript 完美解决对联广告
javascript 完美解决对联广告
//
function couplet(){
if(arguments.length>=1) this.objID = document.getElementById(arguments[0]);
if(arguments.length>=2) this.divTop = arguments[1];
if(arguments.length>=3) this.divPlane = arguments[2];
if(arguments.length>=4) this.scrollDelay = arguments[4];
if(arguments.length>=5) this.waitTime = arguments[5];
if(!this.objID){
alert("对象名【"+ arguments[0] +"】无效,对联无法初始化,请检查对象名称是否正确!");
this.objID = null; return;
}else{
this.objID.style.position="absolute";
this.objID.style.display="block";
this.objID.style.zIndex=9999;
}
if("" == this.objID.style.top){
if(isNaN(this.divTop)){
alert("对象垂直位置(top)参数必须为数字。"); return;
}else{
this.objID.style.top = this.divTop+"px";
}
}
if("" == this.objID.style.left && "" == this.objID.style.right){
if(isNaN(this.divPlane)){
alert("对象水平位置(left||right)参数必须为数字。"); return;
}
if(this.divPlane>0) this.objID.style.left = this.divPlane+"px";
if(this.divPlane<0) this.objID.style.right = Math.abs(this.divPlane)+"px";
}
if(this.scrollDelay<15 || isNaN(this.scrollDelay)) this.scrollDelay = 15;
if(this.waitTime<500 || isNaN(this.waitTime)) this.waitTime = 500;
if(arguments.length>=1) this.start();
}
couplet.prototype.start = function(){
if(null == this.objID) return;
var objCouplet = this;
timer = this.scrollDelay;
objCouplet.lastScrollY = 0;
objCouplet.timerID = null;
objCouplet.startID = function(){
if("block" == objCouplet.objID.style.display){
objCouplet.run();
}else{
clearInterval(objCouplet.timerID);
}
}
objCouplet.Begin = function(){
objCouplet.timerID = setInterval(objCouplet.startID,timer);
} setTimeout(objCouplet.Begin,this.waitTime);
}
couplet.prototype.run = function(){
if(document.documentElement && document.documentElement.scrollTop){
uu_scrY = parseFloat(document.documentElement.scrollTop);
}else if(document.body){
uu_scrY = parseFloat(document.body.scrollTop);
}
uu_divX = parseFloat(this.objID.style.top.replace("px",""));
uu_curTop = .1 * (uu_scrY - this.lastScrollY);
uu_curTop = uu_curTop>0?Math.ceil(uu_curTop):Math.floor(uu_curTop);
this.objID.style.top = parseFloat(uu_divX + uu_curTop) + "px";
this.lastScrollY += uu_curTop;
}
//
function maple_hide(num){
document.getElementById("maple"+num).style.display="none"; }
//
function floatjs(){
new couplet("maple1",100,1);
new couplet("maple2",450,8);
new couplet("maple3",100,-8);
//new couplet("maple4",450,-8);
}
if( window.addEventListener) window.addEventListener('load',floatjs,false);
else window.attachEvent('onload',floatjs);
//
document.write('<div id="maple1"><a href="http://www.k686.com/" target="_blank"><img src="http://www.lygnk.com/images/shinian.jpg" border="0" /></a><div style="position: absolute;width:30px;height:30px;top:0px;right:5px;cursor:pointer" onclick="maple_hide(1)">XX</div></div>');
document.write('<div id="maple2"><a href="http://www.k686.com/" target="_blank"><img src="http://www.lygnk.com/images/shinian.jpg" border="0" /></a><div style="position: absolute;width:30px;height:30px;top:0px;right:5px;cursor:pointer" onclick="maple_hide(2)">XX</div></div>');
document.write('<div id="maple3"><a href="http://www.k686.com/" target="_blank"><img src="http://www.lygnk.com/images/shinian.jpg" border="0" /></a><div style="position: absolute;width:30px;height:30px;top:0px;right:5px;cursor:pointer" onclick="maple_hide(3)">XX</div></div>');
//document.write('<div id="maple4"><a href="http://www.k686.com/" target="_blank"><img src="http://www.lygnk.com/images/shinian.jpg" border="0" /></a></div>');
javascript 完美解决对联广告的更多相关文章
- emlog通过pjax实现无刷新加载网页--完美解决cnzz统计和javascript失效问题
想要更详细了解pjax,需要查看官网 或者看本站文章:jQuery.pjax.js:使用AJAX和pushState无刷新加载网页(官网教程中文翻译) 效果看本站,音乐无刷新播放,代码高亮和复制js加 ...
- [转]javascript对联广告、漂浮广告封装类,多浏览器兼容
封装的JS方法: function $$(element){ if(arguments.length>1){ for(var i=0,elements=[],length=arguments.l ...
- 完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法
完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法 HTML5的语义化标签以及属性,可以让开发者非常方便地实现清晰的web页面布局,加上CSS3的效果渲染,快速建立丰富灵活的web页 ...
- 完美解决IE6中fixed抖动问题的方法
我们可以通过position:fixed来实现元素的固定效果,如网页中底部的"回到顶部菜单",底部的toolbar,对联广告等等,可惜fixed属性在IE6及以下是不支持的.通常的 ...
- 完美解决 Phonegap jQeuryMobile 闪屏 问题
在切换page或者弹出dialog时,会出现闪屏情况,综合网络上各种方法,得出以下方法可完美解决: 1.首先界面页面切换闪屏: 在加载jQuery后,加载jQuery Mobiel之前,插入js语句进 ...
- HTML5 Shiv完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法
这篇文章主要介绍了HTML5 Shiv完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法,需要的朋友可以参考下 HTML5的语义化标签以及属性,可以让开发者非常方便地实现清晰的web页面 ...
- PNG24在ie6下的完美解决方法!(DD_belatedPNG)
原网址:http://www.zjgsq.com/1629.html 之前写过一篇<js+css滤镜设置解决PNG24在IE6下显示问题> 解决方法不是很完美,使用起来也比较麻烦. DD_ ...
- "Uncaught SyntaxError: Unexpected token <"错误完美解决
今天写代码的时候发现了"Uncaught SyntaxError: Unexpected token <" <html>的js错误,而且还是html的第一行,我就 ...
- 完美解决,浏览器下拉显示网址问题 | 完美解决,使用原生 scroll 写下拉刷新
在 web 开发过程中我们经常遇到,不想让用户下拉看到我的地址,也有时候在 div 中没有惯性滚动,就此也出了 iScroll 这种关于滚动条的框架,但是就为了一个体验去使用一个框架好像又不值得,今天 ...
随机推荐
- ganglia安装 by frank
作者是frank. 1.安装epelrpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm2. ...
- msf web_delivery模块攻击
目标机:win7 ip:192.168.31.136 攻击机:kai liunx ip:192.168.31.54 一. ...
- C# .net WPF无边框移动窗体
转自 http://download.csdn.net/detail/xiang348352/3095084 WPF无边框移动窗体,先在<Window>里添加 MouseLeftButto ...
- php分享二十六:读写日志
一:读写日志注意事项: 1:fgets取出日志行后,注意用trim过滤下 2:explode(“\t", $line) 拆分后,注意判断下个数是否正确,如果不正确,怎么处理? 如果某一列 ...
- 【Unity】11.8 关节
分类:Unity.C#.VS2015 创建日期:2016-05-02 一.简介 Unity提供了下面的关节组件:铰链关节(Hinge Joint).固定关节(Fixed Joint).弹簧关节(Spr ...
- 【Unity】6.7 向量和Vector3类
分类:Unity.C#.VS2015 创建日期:2016-04-20 一.简介 在虚拟的游戏世界中,与3D有关的数学知识决定了游戏引擎如何计算和模拟出开发者以及玩家看到的每一帧画面.学习或者回想一下基 ...
- linux如何查看一个进程的堆栈
转自:http://blog.csdn.net/nanjingligong/article/details/8624739 方法一:pstack pidNAME pstack - prin ...
- Scroll的使用
1.给父元素限制宽高 2.给Scroll限制高度,并overflow:hidden; <div class="rank"> <scroll class=" ...
- Android.mk用法整理
[时间:2016-05] [状态:Open] 输出消息 由于Android.mk使用的GNU Make的语法,可以方便的使用.ndk提供了一下三种格式的消息输出: error: debug print ...
- springboot+sqlite+maven+mybatis
https://blog.csdn.net/u012343297/article/details/79163977 ****************************************** ...