一个网页第一次点击任何地方弹出广告页面,第二次就不会弹出jsJavaScript

解决方案 »

  1.   

    <!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-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload=function(){
    var div=document.getElementsByTagName("div")[0];
    div.onclick=function(){
    alert('ad');
    div.onclick=null;
    }
    }
    </script>
    </head><body>
    <div style="position:absolute; left:0px; top:0px; width:100%; height:100%">
    <div>123</div>
    <input type="button" value="ss" />
    <input type="text" value="text" />
    </div>
    </body>
    </html>
    类似这样试试
      

  2.   

    谢谢你,不过我要的不是这种效果啊!我要的是像这个网址那样的:http://www.3454.com/lol
    你试试看看那个效果
      

  3.   

    最上面 放一个 透明的div
    点了 出广告 然后 div消失
      

  4.   

    用jquery
    $(document).click(function(){
       ......弹出广告
       $(document).unbind("click");
    });

    document.onclick=function(){
       ......弹出广告
       document.removeAttribute("onclick");
    };
      

  5.   

    jquery:$("body").one("click", function(){
     alert("广告");
    })