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>‘);
时间: 2024-07-30 04:43:23

javascript 完美解决对联广告的相关文章

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

想要更详细了解pjax,需要查看官网 或者看本站文章:jQuery.pjax.js:使用AJAX和pushState无刷新加载网页(官网教程中文翻译) 效果看本站,音乐无刷新播放,代码高亮和复制js加载成功- 准备文件 编辑模板 header.php 的 head 添加必要文件: jquery-1.11.1.min.js:百度网盘下载 jquery.pjax-1.8.2.min.js:百度网盘下载 下载到模板的 scripts 目录下后将下面两句添加到</head>所有script标签的最前面

谷歌、火狐浏览器下实现JS跨域iframe高度自适应的完美解决方法,跨域调用JS不再是难题!

谷歌.火狐浏览器下实现JS跨域iframe高度自适应的解决方法 导读:今天开发的时候遇到个iframe自适应高度的问题,相信大家对这个不陌生,但是一般我们都是在同一个项目使用iframe嵌套页面,这个ifame高度自适应网上一搜一大把,今天要讲的如何在不同的网站下进行相互的调用跟在同一个网站下是一个效果:例如我在自己的项目里面Iframe  了第一博客的页面  http://www.diyibk.com/   当第一博客的页面高度变化了怎么通知父页面呢? 这个时候在谷歌下肯定是拿不到 ifram

带关闭按钮的跟随窗口移动对联广告代码

http://www.xuecss3.com/qttx-25-2991-1.html <!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"> <

我们这里有仿百度联盟对联广告实现代码

仿百度联盟对联广告源代码展示,主要使用现代浏览器都支持的position:fixed属性,并专门针对ie6做了最大限度的兼容性处理 <style type="text/css"> 02 *{margin:0;padding:0;} 03 body{height:2000px;} 04 .floatAd{width:124px;height:299px; text-align:center; position:fixed;margin-left:0;top:109px; _p

JS写出登陆遮罩层+浮动对联广告

用JS写出 遮罩层登陆框 和 对联广告 并自动跟随滚动条 滚动 保持让用户一直可以看到 好了,天色已晚废话不多说,代码特别详细 有注释,请看代码. ================> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml

可关闭与展开的对联广告代码

<!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"> <head> <meta http-equiv="Content-

jquery两边飘浮的对联广告

<!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"> <head> <meta http-equiv="Content-

蓝色经典的对联广告代码

<html><head><title>蓝色经典的对联广告代码</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body><table><tr><td height="1000"></tr></t

对联广告2

<html><head><title>对联广告</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body style="margin:0px;"><div align="center">  <center>