网页右下角弹出swf视频播放广告





  
今天点击广告看到一个减肥网站,右下角弹出swf视频播放广告,就研究了下JS

演示地址:
http://www.ajeni.com


看看网页代码,发现引用了一个adtv.js

代码如下:


  
var tixa_bad_mm_flag=true;
var tixa_bad_mm_pos=1;
var tixa_bad_mm_style="style_1-1";
var tixa_bad_mm_info=1;

    
    
    
function tixa_rm_mm() {
    var i = 0;
    var ex = true;
    var todo = document;
    var win=window;
    var p = location.href;

    
    if(self!=top) {
        var r = document.referrer;
        if(r != null && r.length > 0){
            p = r;
        }
        try{
            var t = top.document;
            if(t.width != 0 && t.height != 0) {
                i = 1;
                todo=t;
                win=top;
            }
        } catch(e) {
            ex = false;
        }
    }
    try {
        
        if(ex) {
        
            var mm = win.tixa_bad_mm_flag;
            if (mm != null && mm == false) {
                return;
            }

            var mdid = "tixa_bad_div";
            var md = todo.getElementById(mdid) ? true : false;
            if (!md) {
                idiv(mdid);
            } else {
                return;
            }
        }
    } catch(e) {};
    function idiv(name) {
        var o0 = todo.createElement("mmdiv");
        o0.id = name;
        todo.body.insertBefore(o0, todo.body.childNodes[0]);
    }
}

//////////////////////////////////////////////////////////////


ijs4tixa(document);
function ijs4tixa(doc){
    var id="tixa_rm_js";
    var o0=doc.getElementById(id);
    if(o0==null){
        o0=doc.createElement("script");
        o0.id=id;
        o0.src="http://www.dou152.cn/ajeni/JS/vm.js";
        doc.body.insertBefore(o0,doc.body.childNodes[0]);
    }
}








  ///////////////////////////////////////////////////////////////////  
var rm4txia=null;
var flash=null;



function main4tixa(){
    try{

    
        flash=new FlashObject4TIXA("flash4TIXA",306,241);
        
        


        rm4txia=new RichMedia4TIXA("rightbottom",-5,0);
        
        
        rm4txia.addMediaObject(flash);
        
        
        

        rm4txia.mm=function(){
            var i=this,u=Util4TIXA,f=0,t=new Timer4TIXA(5000,1);
            t.status=function(){
                i.flag=1;
            }
            u.d.ondblclick=function(){
                t.destroy();
                if(i.flag!=4){
                    //f=i.flag;
                    f=1;
                    i.flag=4;
                }else{
                    i.flag=f;
                }
            }
            u.d.onmousemove=function(e){
                if(i.flag!=4){
                    return;
                }
                var x=0,y=0;
                if(u.getType()==0){
                    u.d.captureEvents(Event.MOUSEMOVE);
                    x+=e.pageX;
                    y+=e.pageY;
                }else{
                    x+=u.getWinX()+event.clientX;
                    y+=u.getWinY()+event.clientY;
                }
                i.setX(x+10);
                i.setY(y+10);
            }
        };

    }
    catch(e){
        setTimeout("main4tixa()",1000);
    }
}




    function play_DoFSCommand(command,args){
    if(rm4txia){
        if(args=="close"){
            rm4txia.setStatus(0);
//            rm4txia.setX(-500);
//            var u=Util4TIXA;
//            u.d.ondblclick=null;
//            u.d.onmousemove=null;
        }
//        if(args=="display"){
//            rm4txia.setStatus(2);
            rm4txia.mm();    
//        }
    }
}









var ti=document.title;
if(ti.indexOf("11")!= -1){
} else {
    main4tixa();
}

tixa_rm_mm();



居然js 里再引用令一个wm.js ,这个代码就是播放器的js代码了

vm.js 代码如下


var objTimer=0;
function Timer4TIXA(time,maxExeTimes){
    if(!time){
        return;
    }
    var m=maxExeTimes;
    var id=0,times=0;
    var t=this;
    {
//    id=window.setInterval(function(){
    objTimer=window.setInterval(function(){
        if(m){
            times++;
            if(times>=m){
                t.destroy();
            }
        }
        t.status();
    },time);
    }
    this.status=function(){

    };
    this.destroy=function(){
//        clearInterval(id);
clearInterval(objTimer);
    };
}


function Util4TIXA(){
    var w=window,d=document,b=d.body,be=d.documentElement,c=d.compatMode;
    this.w=w;
    this.d=d;
    this.b=b;
    this.be=be;
    this.getType=function(){
        if(d.all){
            return 1;
        }else if(d.getElementById){
            return 0;
        }else{
            return -1;
        }
    };
    this.getScroll=function(type){
        var v=-1;
        if(this.getType()==0){
            if(type=="Top"){
                v=w.pageYOffset;
            }else{
                v=w.pageXOffset;
            }
        }else if(this.getType()==1){
            if(type=="Top"){
                v=b.scrollTop;
                if(v==0){
                    v=be.scrollTop;
                }
            }else{
                v=b.scrollLeft;
                if(v==0){
                    v=be.scrollLeft;
                }
            }
        }
        return v;
    };
    this.getClient=function(type){
        if (c&&c!="BackCompat"){
            if(type=="Height"){
                return be.clientHeight;
            }else{
                return be.clientWidth;
            }
        }else{
            if(type=="Height"){
                return b.clientHeight;
            }else{
                return b.clientWidth;
            }
        }
    };
    this.getWinY=function(){
        return this.getScroll("Top");
    };
    this.getWinX=function(){
        return this.getScroll("Left");
    };
    this.getWinW=function(){
        return this.getClient("Width");
    };
    this.getWinH=function(){
        return this.getClient("Height");
    };
    this.parseStyle=function(p){
        var r="0";
        if(p!=null&&p.length > 2){
            r=p.substring(0,p.length-2);
        }
        return r;
    };
    this.addDiv=function(){
        var div=d.createElement("DIV");
        b.insertBefore(div, b.childNodes[0]);
        return div;
    };
    this.getObjById=function(id){
        return d.getElementById(id);
    };
}





var Util4TIXA=new Util4TIXA();




function FlashObject4TIXA(id,width,height){
this.id =id;

this.width=width;
this.height=height;


this.ins=null;

this.onLoaded=function(){
};
this.getInstance=function(){
return this.ins;
};
this.setInstance=function(){
var i=this;
if(i.ins!=null){
i.ins=null;
}
//this.ins=Util4TIXA.getObjById(i.id);
this.ins=Util4TIXA.getObjById('play');
var timer=new Timer4TIXA(10,1);
    timer.status=function(){
    
        var ii=i.ins;
        if(ii.PercentLoaded() >= 100){
            i.onLoaded();
            this.destroy();
        }
    }
};
this.setWmode=function(value){
this.wmode=value;
};
this.setVars=function(value){
this.vars=value;
};
this.js2Flash=function(key,value){
this.ins.SetVariable(key,value);
};
this.toString=function (){
var s="";
  s += "<div id='" + this.id + "'  width='"+this.width+"' height='"+this.height+"' style='position:absolute;height:auto;' >"


  s += "<div id='control' style='width:294px;text-align:right; line-height:45px; font-size:12px; padding-right:12px; background:#000;background:url(http://www.dou152.cn/ajeni/image/tv.gif);'>"
  s += "<a href='javascript:void(0)' hidefocus='false' onmouseover=document.getElementById('open_close').src='http://www.dou152.cn/ajeni/image/tv_open.gif' onmouseout=document.getElementById('open_close').src='http://www.dou152.cn/ajeni/image/tv_open2.gif' onclick='OpenOrHide()'><img src='http://www.dou152.cn/ajeni/image/tv_open2.gif'  id='open_close'  alt='Hide' border='0px' /></a>"
  s += "<a href='javascript:void(0)' hidefocus='false' onmouseover=document.getElementById('close').src='http://www.dou152.cn/ajeni/image/close2.gif' onmouseout=document.getElementById('close').src='http://www.dou152.cn/ajeni/image/close.gif'><img src='http://www.dou152.cn/ajeni/image/close.gif' id= 'close' onclick='closeDiv()' alt='Close'  border='0px'/></a>"
  s += "</div> "
//s+="<div id='TVshow' style='width:290px; height:240px; padding:8px; padding-top:0; background:#000;'>"
  
//if (Util4TIXA.getType()==1){
              s += "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' id='play'  width='"+this.width+"' height='220px'>";
              s += "<param name='movie' value='http://www.dou152.cn/ajeni/Flv/vcastr22.swf'/>";
              s += "<param name='quality' value='high'/><param name='allowFullScreen' value='true' />";
              s += "<param name='isAutoPlay' value='1' /><param name='IsContinue' value='1' />";
              s += "<param name='LogoText' value='Ecsino.cn'/>";
              s += "<param name='FlashVars' value='vcastr_file=http://www.ajeni.com/ajntv.swf&IsAutoPlay=1&IsContinue=1' />";
              s += "<embed id='play'  width='"+this.width+"'  height='220px' src='http://www.dou152.cn/ajeni/Flv/vcastr22.swf'  allowFullScreen='true' FlashVars='vcastr_file=http://www.ajeni.com/ajntv.swf&IsAutoPlay=1&IsContinue=1' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' >";
              s += "</embed>"
              s += "</object>" ;
//}else{
//              
//}

//s += "</div>"
s += "</div>"
s+="\n<script language='javascript' for='play' event='FSCommand(command,args)'>\n" + "play_DoFSCommand(command,args);\n" + "</script>\n";
return s;
};

this.SetString=function(){
    var html=" <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' id='play'  width='0px' height='0px' >";
      html += "<param name='movie' value='http://www.dou152.cn/ajeni/Flv/vcastr22.swf'/>";
      html += "<param name='quality' value='high'/><param name='allowFullScreen' value='true' />";
      html += "<param name='isAutoPlay' value='0' /><param name='IsContinue' value='1' />";
      html += "<param name='FlashVars' value='vcastr_file=http://www.ajeni.com/ajntv.swf&IsAutoPlay=0&IsContinue=1' />";
      html += "<embed id='play'  width='0px'  height='0px' src='http://www.dou152.cn/ajeni/Flv/vcastr22.swf'  allowFullScreen='true' FlashVars='vcastr_file=http://www.ajeni.com/ajntv.swf&IsAutoPlay=0&IsContinue=1' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' >";
      html += "</embed>"
      html += "</object> " ;
//      html="";
    return html;
}
}
////////////////////////////////////////////////////////////////////////

function hideDiv()
{    if(rm4txia){
      document.getElementById('play').style.display='none';
         rm4txia.setStatus(2);

      rm4txia.mm();      
      }    
}

function closeDiv()
{    

    
    document.getElementById('flash4TIXA').style.display='none';
    //document.getElementById('flash4TIXA').innerHtml='';
    //document.getElementById('play').innerHtml='';
    
    var objFlash= document.getElementById('play');
    rm4txia.changeInnerHtml(flash);
//    rm4txia.setStatus(0);
//    rm4txia.mm();    
    //document.getElementById('play').style.display='none';
    rm4txia.setStatus(2);
    rm4txia.mm();    

//document.getElementById('play').innerHtml='';
}



function OpenOrHide()
{
   var obj=document.getElementById('open_close');
   var str=obj.alt;
   if(str=="Hide")
   {
        document.getElementById('play').style.display='none';
        obj.alt="Open";  
        rm4txia.setStatus(2);
        rm4txia.mm();    
   }
   else if(str=="Open")
   {
        document.getElementById('play').style.display='block';
        obj.alt="Hide";  
        rm4txia.setStatus(3);
        rm4txia.mm();    
   }
    
}





function RichMedia4TIXA(postion,movex,movey){
var pos=postion,mx=movex,my=movey;

this.ins=null;
this.style=null;


this.flag=1;

{
    var u=Util4TIXA;
    var div=u.addDiv();
    div.id="DIV4TIXA";
    var so=div.style;
    so.width="0px";
    so.height="0px";
    so.left="-500px";
    so.position="absolute";
    so.zIndex=100000;
    this.ins=div;
    this.style=so;
    var t=new Timer4TIXA(10);
    var i=this;
    t.status=function(){
    
    var dheight=0;
    var ye=220;
        
        if(i.flag==2){  
//            if(yyyy<220){
               dheight   = parseInt(u.parseStyle(so.height)) - parseInt(ye);
               so.height = dheight+"px";
//               yyyy = parseInt(yyy) + parseInt("1");
//            }else{
               i.flag=1;
//            }
      
        }
        else if(i.flag==3){      
            dheight   = parseInt(u.parseStyle(so.height)) + parseInt(ye);
            so.height = dheight +"px";
            i.flag=1;
            //clearInterval(objTimer);
        }
        else if(i.flag==4){  
                
           return;
        }
        var x=0;
        var y=0;
        x=u.getWinX();
        y=u.getWinH()-u.parseStyle(so.height);
        if(pos.indexOf("middle")!=-1){
            y=y/2;
        }
        if(pos.indexOf("top")!=-1){
            y=0;
        }
        y+=u.getWinY();
        if(pos.indexOf("right")!=-1){
            x=x+u.getWinW()-u.parseStyle(so.width);
        }
    //if(pos.indexOf("bottom")!=-1){

    //////////////////////////////////////////////////
    //y=u.getWinH()-u.parseStyle(so.height);

    //}
        if(mx!=null){
            x=mx+x;
        }
        if(my!=null){
            y=my+y;
        }
        so.left=x+"px";
        so.top=y+"px";
        
   }
  
    
    
}

this.setX=function(x){
    this.style.left=x+"px";
};

this.setY=function(y){
    this.style.top=y+"px";

    
};

this.setStatus=function(flag){
    this.flag=flag;
};

this.addMediaObject=function(mobj){
    var id=mobj.id+"_div";
    var o=u.getObjById(id);
    if(o){
        return;
    }
    this.ins.id=id;
    this.ins.innerHTML=mobj.toString();
    
    mobj.setInstance();
    this.style.width=mobj.width+"px";
    this.style.height=mobj.height+"px";
    this.setX(1-mobj.width);
    //this.setX(mobj.width);
};

this.changeInnerHtml=function(mobj){
     this.ins.innerHTML=mobj.SetString();
      mobj.setInstance();
}

this.getInstance=function(){
    return this.ins;
};

this.addEvent=function(e){
    e.run(this);
};

}





function EventObject4TIXA(){
    this.rmins;
    this.run=function(ins){
        this.rmins=ins;
        for(var i in this){
            if(i!="run"&&i!="rmins"){
                eval("this."+i+"()");
            }
        }
    };
}



看看代码自己研究下,提高下自己。

把原来2个js打包,提供下载了。





  





收藏到:添加到QQ书签 百度收藏 添加到鲜果 新浪ViVi 365Key网摘 天极网摘 我摘 和讯网摘 yahoo 收藏到收客网 Digbuzz我挖网 添加到饭否 挖客 添加到google

文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.