>  기사  >  웹 프론트엔드  >  js를 이용한 플로팅박스 광고 닫기 특수 효과에 대한 자세한 설명

js를 이용한 플로팅박스 광고 닫기 특수 효과에 대한 자세한 설명

零下一度
零下一度원래의
2017-06-29 09:26:581914검색

충돌을 피하기 위해 광고 기능을 닫는 데 close() 이름을 직접 사용할 수 없다는 점에 유의하세요.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>无标题文档</title><style type="text/css">
        #apDiv1 {position: absolute;left: 251px;top: 51px;width: 529px;height: 210px;z-index: 2;background-color: #0000FF;}
        #closebt {position: absolute;top: 0;right: 0;background: red;}
        #apDiv2 {position: absolute;left: 128px;top: 381px;width: 912px;height: 18663px;z-index: -1;background-color: #FF0000;}-->
        </style><script>var xx = 0;function init() {//获取元素的top值            xx = document.getElementById("apDiv1").offsetTop;
        }function aa() {if (document.body.scrollTop) 
        {//兼容谷歌                
        document.getElementById("apDiv1").style.top = xx + document.body.scrollTop + "px";
            } else {//兼容ie,火狐                
            document.getElementById("apDiv1").style.top = xx + document.documentElement.scrollTop + "px";
            }
        }
        window.onscroll = aa;function closetext() {
            document.getElementById("closebt").style.display="none";
            document.getElementById("apDiv1").style.display="none";
        }</script>
        </head>
        <body onload="init()">
        <div id="apDiv1"><span id="closebt"><a href="#" onclick="closetext()">可关闭</a>
        </span></div><div id="apDiv2">
        </div>
        </body>
        </html>

위 내용은 js를 이용한 플로팅박스 광고 닫기 특수 효과에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.