您现在的位置:首页 >> 前端 >> 内容

canvas之加载前出现加载logo的使用(代码)

时间:2018/4/12 14:44:53 点击:

  核心提示:canvas画布模拟加载页面出现加载logo的画面:!DOCTYPE htmlhtmlheadmeta charset=utf-8meta http-equiv=X-UA-Compatible con...

canvas画布模拟加载页面出现加载logo的画面:

<!DOCTYPE html>  
<html>  
<head>  
<meta charset="utf-8">  
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  
<title>页面2</title>  
<meta name="description" content="">  
<meta name="keywords" content="">  
<link href="" rel="stylesheet">  
<style type="text/css">  
    .loading{  
        position: fixed;  
        width: 100%;  
        height: 100%;  
        z-index: 555555;  
        background:#ddd;  
    }  
    a{  
        display: block;  
        width: 500px;  
        height: 500px;  
        background: blue;  
        line-height: 500px;  
        color: #fff;  
            }  
</style>  
</head>  
<body>  
    <p style="text-align: center;">  
          
        <p class="loading" id="isshow">  
            <canvas id="loading" style="margin-top:100px; "></canvas>  
              
        </p>  
        <a href="page1.html">页面</a>  
    </p>  
</body>  
<script type="text/javascript">  
    var gettext=0;  
    function loading(){  
    var loading=document.getElementById('loading');  
    var loadingcontent=loading.getContext('2d');  
    var text="加载中";  
    var addtext="."  
    loadingcontent.font = "35px 宋体";    
    loadingcontent.fillStyle = "black";   
    gettext+=1;  
    if(gettext<=4){  
        if(gettext==1){  
        loadingcontent.clearRect(0,0,loading.width,loading.height);   
        loadingcontent.fillText('加载中',30,40)  
        }  
        if(gettext==2){  
        loadingcontent.clearRect(0,0,loading.width,loading.height);   
        loadingcontent.fillText('加载中。',30,40)  
        }  
        if(gettext==3){  
        loadingcontent.clearRect(0,0,loading.width,loading.height);   
        loadingcontent.fillText('加载中。。',30,40)  
        }  
        if(gettext==4){  
        loadingcontent.clearRect(0,0,loading.width,loading.height);   
        loadingcontent.fillText('加载中。。。',30,40)  
        }localStorage.i='0';  
          
    }if(gettext==6){  
        gettext=0;  
        localStorage.i='1';  
    }  
    console.log(localStorage.i)  
    }  
    window.onload=function() {  
        var showtime=setInterval("loading()",1000);  
        var cancel=setInterval('clear()',1000);  
          
    }  
  
    function clear(){  
        var ishow=document.getElementById('isshow');  
        if(localStorage.i=='1'){  
            ishow.style.display='none';  
        }  
    }  
      
</script>  
</html> 

Tags:CA AN NV VA 
作者:网络 来源:mafia_asla