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 这种关于滚动条的框架,但是就为了一个体验去使用一个框架好像又不值得,今天 ...
随机推荐
- Mysql:MyIsam和InnoDB的区别
MyISAM: 这个是默认类型,它是基于传统的ISAM类型,ISAM是Indexed Sequential Access Method (有索引的 顺序访问方法) 的缩写,它是存储记录和文件的标准方法 ...
- Activity 变成对话框,然后再隐藏?
由于继续需要做一些无感操控的工作,之前也记录了下利用悬浮窗的方法.今天突然发现原来activity可以直接嗯嗯嗯啊. 首先我在AndroidManifest里给activity添加了如下一行: and ...
- Spring Hibernate JPA 联表查询 复杂查询(转)
今天刷网,才发现: 1)如果想用hibernate注解,是不是一定会用到jpa的? 是.如果hibernate认为jpa的注解够用,就直接用.否则会弄一个自己的出来作为补充. 2)jpa和hibern ...
- Java代码通过API操作HBase的最佳实践
HBase提供了丰富的API.这使得用Java连接HBase非常方便. 有时候大家会使用HTable table=new HTable(config,tablename);的方式来实例化一个HTabl ...
- ACM会议列表与介绍(2014/05/06)
Conferences ACM SEACM Southeast Regional Conference ACM Southeast Regional Conference the oldest, co ...
- 关于 隐藏元素(样式为 display: none 的元素)及其子元素 获取不到高度的问题
IE 和 Edge 中都是这样,Chrome中好像还好. 方法就是换一个样式,还有一个控制显示隐藏的:visibility 相关文档:http://www.w3school.com.cn/cssref ...
- 开发前奏曲之添加Android SDK平台工具
原文:http://android.eoe.cn/topic/android_sdk Android SDK分离不同部位的SDK成单独的下载包.您已经安装只包含SDK工具的SDK入门包.要开发一个An ...
- <![CDATA[]]>和转义字符
被<![CDATA[]]>这个标记所包含的内容将表示为纯文本,比如<![CDATA[<]]>表示文本内容“<”. 此标记用于xml文档中,我们先来看看使用转义符的情 ...
- nginx 404 403等错误信息页面重定向到网站首页或其它事先指定的页面
server { listen 80; server_name www.espressos.cn; location / { root html/www; index index.html index ...
- 2-7-集合运算(A-B)∪(B-A)-线性表-第2章-《数据结构》课本源码-严蔚敏吴伟民版
课本源码部分 第2章 线性表 - 集合运算(A-B)∪(B-A) ——<数据结构>-严蔚敏.吴伟民版 ★有疑问先阅读★ 源码使用说明 链接☛☛☛ <数据结构-C语言 ...