第一次打开网站点击任意跳转指定网址

首先设置一个div层 以及css <div id="firstMask" style="display: none;"></div> <style type="text/css">         html,body {             height: 100%;             po...

首先设置一个div层 以及css

<div id="firstMask" style="display: none;"></div>
<style type="text/css">
        html,body {
            height: 100%;
            position: relative;
        }
        #firstMask {
            width: 100%;
            height: 100%;
            position: fixed;
            display: none;
            top: 0;
            left: 0;
            z-index: 9999;
            cursor: pointer;
            background-color: transparent;
        }
    </style>

js代码

<script>     
$(document).ready(function() {    
if(!window.name) {    
//console.log("第一次打开");    
window.name = "yuttname" ;    
$("#firstMask").show(); // + 新增    
$('#firstMask').click(function () {    
$("#firstMask").hide()    
if(location.href.indexOf('www.isiyuan.net') !== -1){    
window.open("http://www.baidu.com");//第一次打开时设置name    
}else{    
window.open("http://www.baidu.com");//第一次打开时设置name    
}    
localStorage.clear(); //清全部缓存    
});    
} else { // 不是第一次打开 将 遮罩去掉    
$("#firstMask").hide()    
}    
});    
</script>


  • 发表于 2021-04-16 06:02
  • 阅读 ( 918 )
  • 分类:互联网

0 条评论

请先 登录 后评论
wQ5335
wQ5335

695 篇文章

你可能感兴趣的文章