欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

页面关闭时弹出广告

发布时间:2023/12/18 33 豆豆
生活随笔 收集整理的这篇文章主要介绍了 页面关闭时弹出广告 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
<head >
    
<title>关闭时弹出页demo,暂时支持ie版本</title>

    
<script type="text/javascript">
        
var G_Event;
        
function OpenUrl(url) {
            document.getElementById(
"palyer").launchURL(url);
        }
        
function Init() {
            document.write(
"<object id='palyer' width='0' height='0' classid='CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6'></object>");
        }
        
function BeginClose() {
            window.open(
"http://www.baidu.com");     //广告方式   
            OpenUrl("http://www.baidu.com"); //window player 方式
        }
        window.onmousemove 
= function(e) {
            G_Event 
= e ? e : window.event;
        }
        window.onbeforeunload 
= function(e) {
            e 
= window.event ? window.event : G_Event;
            
if (window.event) { //ie
                if (e.clientY < 0 || e.altKey) {
                    BeginClose();                
                } 
else {
                    
//ie刷新
                }
            }
            
else {
                BeginClose();
            }
        }
        
    
</script>
    
<script>
            
//必须的
            Init();
    
</script>
</head>
<body>

</body>

转载于:https://www.cnblogs.com/skyangell/archive/2011/03/30/1999356.html

总结

以上是生活随笔为你收集整理的页面关闭时弹出广告的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。