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 完美解决对联广告的更多相关文章

  1. emlog通过pjax实现无刷新加载网页--完美解决cnzz统计和javascript失效问题

    想要更详细了解pjax,需要查看官网 或者看本站文章:jQuery.pjax.js:使用AJAX和pushState无刷新加载网页(官网教程中文翻译) 效果看本站,音乐无刷新播放,代码高亮和复制js加 ...

  2. [转]javascript对联广告、漂浮广告封装类,多浏览器兼容

    封装的JS方法: function $$(element){ if(arguments.length>1){ for(var i=0,elements=[],length=arguments.l ...

  3. 完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法

    完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法   HTML5的语义化标签以及属性,可以让开发者非常方便地实现清晰的web页面布局,加上CSS3的效果渲染,快速建立丰富灵活的web页 ...

  4. 完美解决IE6中fixed抖动问题的方法

    我们可以通过position:fixed来实现元素的固定效果,如网页中底部的"回到顶部菜单",底部的toolbar,对联广告等等,可惜fixed属性在IE6及以下是不支持的.通常的 ...

  5. 完美解决 Phonegap jQeuryMobile 闪屏 问题

    在切换page或者弹出dialog时,会出现闪屏情况,综合网络上各种方法,得出以下方法可完美解决: 1.首先界面页面切换闪屏: 在加载jQuery后,加载jQuery Mobiel之前,插入js语句进 ...

  6. HTML5 Shiv完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法

    这篇文章主要介绍了HTML5 Shiv完美解决IE(IE6/IE7/IE8)不兼容HTML5标签的方法,需要的朋友可以参考下 HTML5的语义化标签以及属性,可以让开发者非常方便地实现清晰的web页面 ...

  7. PNG24在ie6下的完美解决方法!(DD_belatedPNG)

    原网址:http://www.zjgsq.com/1629.html 之前写过一篇<js+css滤镜设置解决PNG24在IE6下显示问题> 解决方法不是很完美,使用起来也比较麻烦. DD_ ...

  8. "Uncaught SyntaxError: Unexpected token <"错误完美解决

    今天写代码的时候发现了"Uncaught SyntaxError: Unexpected token <" <html>的js错误,而且还是html的第一行,我就 ...

  9. 完美解决,浏览器下拉显示网址问题 | 完美解决,使用原生 scroll 写下拉刷新

    在 web 开发过程中我们经常遇到,不想让用户下拉看到我的地址,也有时候在 div 中没有惯性滚动,就此也出了 iScroll 这种关于滚动条的框架,但是就为了一个体验去使用一个框架好像又不值得,今天 ...

随机推荐

  1. springboot 多模块 maven 项目构建jar 文件配置

    最近在写 springboot 项目时,需要使用多模块,遇到了许多问题. 1 如果程序使用了 java8 的一些特性,springboot 默认构建工具不支持.需要修改配置 ... </buil ...

  2. linux分享四:cron系统

    cron相关文件: /etc/cron.monthly/ /etc/cron.weekly/ /etc/cron.daily/ /etc/cron.hourly/ /etc/cron.d/ /etc/ ...

  3. 腾讯云服务器 - 安装redis3.2.9以及集群

    redis大家都知道,服务器上必不可少的,那么在生产环境下安装的步骤和虚拟机里也是差不多的 官网上最新稳定版是3.2.9,而4.0的更新比较大,但是比几个还是beta版嘛 下载并且上传压缩包至云服务器 ...

  4. Atitit 图像处理 halcon类库的使用  范例边缘检测 attilax总结

    Atitit 图像处理 halcon类库的使用  范例边缘检测 attilax总结 1.1. 安装halcon11 ..体积大概1g压缩模式1 1.2. Halcon的科技树1 1.3. 启动 &qu ...

  5. 每日英语:How the College Bubble Will Pop

    The American political class has long held that higher education is vital to individual and national ...

  6. Unity3d中默认函数调用顺序(MonoBehaviour)

    首先要明确的是MonoBehaviour是每个脚本的基类.每个Javascript脚本自动继承MonoBehaviour.使用C#或Boo时,需要显式继承MonoBehaviour.         ...

  7. 【数据库】悲观锁与乐观锁与MySQL的MVCC实现简述

    悲观锁 悲观锁,就是一种悲观心态的锁,每次访问数据时都会锁定数据: 乐观锁 乐观锁,就是一种乐观心态的锁,每次访问数据时并不锁定数据,期待数据并没作修改,如果数据没被修改则作具体的业务 应用程序上使用 ...

  8. (转)大白话讲解如何给github上项目贡献代码

    转自:https://site.douban.com/196781/widget/notes/12161495/note/269163206/ 2013-03-30 22:53:55   本文献给对g ...

  9. 【Git】Git与GitHub 入门

    GitHub GitHub是一个基于git的代码托管平台,付费用户可以建私人仓库,我们一般的免费用户只能使用公共仓库,也就是代码要公开. 对于一般人来说公共仓库就已经足够了,而且我们也没多少代码来管理 ...

  10. Windows / VS下不同类型变量转换

    [时间:2016-07] [状态:Open] [关键词:windows,vs,mfc,类型转换] 在实际编码中经常遇到不同类型及编码方式的字符串.变量之间的转换,比如Unicode->char. ...