如果那广告是flash,关闭时可把它停止播放

解决方案 »

  1.   

    不是flash广告,是纯图片的
    如何清除定时器?下面是一段漂浮广告代码//瓢浮广告
    document.write("<div id=\"SiteMove\" style=\"position:absolute\">");
    document.write("<a href=\"#\" target=\"_blank\"><IMG border=\"0\" src=\"/wdwj/images/ggtp/pfgg.gif\"  width=\"100\" height=\"100\" border=\"0\"></a><br><a href=JavaScript:; onclick=\"SiteMove.style.display = 'none'\">关闭</a>");
    document.write("</div>");var x = 50,y = 60;
    var xin = true, yin = true;
    var step = 1;
    var delay = 30;
    var obj=document.getElementById("SiteMove");
    function floatAD() {
    var L=T=0;
    var R= document.body.clientWidth-document.getElementById("SiteMove").offsetWidth;
    var B = document.body.clientHeight-document.getElementById("SiteMove").offsetHeight;
    document.getElementById("SiteMove").style.left = x + document.body.scrollLeft;
    document.getElementById("SiteMove").style.top = y + document.body.scrollTop;
    x = x + step*(xin?1:-1); 
    if (x < L) { xin = true; x = L} 
    if (x > R){ xin = false; x = R} 
    y = y + step*(yin?1:-1) 
    if (y < T) { yin = true; y = T } 
    if (y > B) { yin = false; y = B } 
    }
    var itl= setInterval("floatAD()", delay) 
    obj.onmouseover=function(){clearInterval(itl)} 
    obj.onmouseout=function(){itl=setInterval("floatAD()", delay)}
    // JavaScript Document
    lastScrollY=0;
    function heartBeat(){ 
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop
    else
        {/*Netscape stuff*/}
        
    //alert(diffY);
    percent=.1*(diffY-lastScrollY); 
    if(percent>0)percent=Math.ceil(percent); 
    else percent=Math.floor(percent); 
    document.getElementById("lovexin12").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";
    document.getElementById("lovexin14").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";lastScrollY=lastScrollY+percent; 
    //alert(lastScrollY);
    }
      

  2.   

    在关闭的那里改成:
    this.parentElement.parentElement.removeChild(document.getElementById("SiteMove"));
    试试,不过在移除之前要clearInterval(itl)一下写成函数:
    function closeDiv(o){
        if(itl!=null) clearInterval(itl);
        o.parentElement.parentElement.removeChild(document.getElementById(this.parentElement.id));
    }改一下关闭那地方:
    document.write(" <a href=\"#\" target=\"_blank\"> <IMG border=\"0\" src=\"/wdwj/images/ggtp/pfgg.gif\"  width=\"100\" height=\"100\" border=\"0\"> </a> <br> <a href=JavaScript:; onclick=\"closeDiv(this)\">关闭 </a>"); 这样子去试试
      

  3.   

    o.parentElement.parentElement.removeChild(document.getElementById(this.parentElement.id)); 
    好像可以改成
    o.parentElement.parentElement.removeChild(this.parentElement); 
      

  4.   

    汗死了,o.parentElement.parentElement.removeChild(o.parentElement); 这样子
      

  5.   

    现在把飘浮去掉了,只有对联和浮标,再请教一下如何将这两种给kill掉,谢谢
    代码如下://对联广告// JavaScript Document
    lastScrollY=0;
    function heartBeat(){ 
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop
    else
        {/*Netscape stuff*/}
        
    //alert(diffY);
    percent=.1*(diffY-lastScrollY); 
    if(percent>0)percent=Math.ceil(percent); 
    else percent=Math.floor(percent); 
    document.getElementById("lovexin12").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";
    document.getElementById("lovexin14").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";lastScrollY=lastScrollY+percent; 
    //alert(lastScrollY);
    }suspendcode12="<DIV id=\"lovexin12\" style='left:0px;POSITION:absolute;TOP:5px;'><a href='#' title='#' target='_blank'><img border=0 src=/wdwj/images/ggtp/dlgg.gif width=100 height=100><br><a href=JavaScript:; onclick=\"lovexin12.style.visibility='hidden';lovexin14.style.display = 'none'\">关闭对联</a>&nbsp;<a href=JavaScript:; onclick=\"lovexin12.style.visibility='hidden';lovexin14.style.display = 'none'\;bottomAD.style.display = 'none';bottomAD1.style.display = 'none'\"><font color=#FF00000>一键关闭</font></a></div>"suspendcode14="<DIV id=\"lovexin14\" style='right:0px;POSITION:absolute;TOP:5px;'><a href='#' title='#' target='_blank'><img border=0 src=/wdwj/images/ggtp/dlgg.gif width=100 height=100><br><a href=JavaScript:; onclick=\"lovexin14.style.display = 'none';lovexin12.style.visibility='hidden'\">关闭对联</a></div>"document.write(suspendcode12); 
    document.write(suspendcode14); 
    window.setInterval("heartBeat()",1);// JavaScript Document
    lastadScrollY=0;
    function bottomscroll(){ 
    var diffadY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffadY = document.documentElement.scrollTop;
    else if (document.body)
        diffadY = document.body.scrollTop
    else
        {/*Netscape stuff*/}
        
    //alert(diffadY);
    percent=.1*(diffadY-lastadScrollY); 
    if(percent>0)percent=Math.ceil(percent); 
    else percent=Math.floor(percent); 
    document.getElementById("bottomAD").style.top=parseInt(document.getElementById("bottomAD").style.top)+percent+"px";
    document.getElementById("bottomAD1").style.top=parseInt(document.getElementById("bottomAD1").style.top)+percent+"px";lastadScrollY=lastadScrollY+percent; 
    //alert(lastScrollY);
    }
    var lngTop=0;
    var lngHeight=0;
    if (document.documentElement && document.documentElement.clientHeight)
        lngHeight = document.documentElement.clientHeight;
    else if (document.body)
        lngHeight = document.body.clientHeight
    else
        {/*Netscape stuff*/}//浮标广告
    lngHeight=parseInt(lngHeight);
    if (parseInt(lngHeight)>220) lngTop=parseInt(lngHeight-160); else lngTop=60;
    bottomhtml="<DIV id=\"bottomAD\" style='right:1px;POSITION:absolute;TOP:" + lngTop + "px;'><a href=JavaScript:; onclick=\"bottomAD.style.display = 'none';bottomAD1.style.display = 'none'\">关闭浮标</a><br><a href='#' title='#' target='_blank'><img border=0 src=/wdwj/images/ggtp/366555.gif width=200 height=150></a></div>"
    bottomhtml1="<DIV id=\"bottomAD1\" style='left:1px;POSITION:absolute;TOP:" + lngTop + "px;'><a href=JavaScript:; onclick=\"bottomAD1.style.display = 'none';bottomAD.style.display = 'none'\">关闭浮标</a><br><a href='#' title='#' target='_blank'><img border=0 src=/wdwj/images/ggtp/cpwgood.gif width=200 height=150></a></div>"
    document.write(bottomhtml + bottomhtml1); 
    window.setInterval("bottomscroll()",1);
      

  6.   

    <a href=JavaScript:; onclick=\"bottomAD.style.display = 'none';bottomAD1.style.display = 'none'\">关闭浮标 </a> 这个,改成onclick="closeDiv1()"function closeDiv1(){
        var bp=document.getElementById("bottomAD").parentElement;
        var bp1=document.getElementById("bottomAD1").parentElement;
        bp.removeChild(document.getElementById("bottomAD"));
        pb1.removeChild(document.getElementById("bottomAD1"));
    }
    对联同样
    function closeDiv2(){
        var bp=document.getElementById("lovexin12").parentElement;
        var bp1=document.getElementById("lovexin14").parentElement;
        bp.removeChild(document.getElementById("lovexin12"));
        pb1.removeChild(document.getElementById("lovexin14"));
    }