首页 > html乱码

html乱码

今天在写页面时。前一秒还好好的,再刷新一下就乱码了

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #div1{
            width: 150px;
            height: 200px;
            background-color: green;
            position: absolute;
            left: -150px;
        }
        #div1 span{
            width: 20px;
            height: 60px;
            line-height: 20px;
            background-color: blue;
            position: absolute;
            right: -20px;
            top: 70px;

        }
    </style>
    <script>
         window.onload=function(){
             var mydiv1=document.getElementById('div1');
             mydiv1.onmouseover=function(){
                 startmove(0);
             };
             mydiv1.onmouseout=function(){
                 startmove(-150);
             }
         }
         var timer=null;
         function startmove(itarget){
             var mydiv1=document.getElementById('div1');
             var speed=0;
             if(mydiv1.offsetLeft>itarget)
             {
                 speed=-10;
             }
             else
             {
                 speed=10;
             }
             clearInterval(timer);
             timer=setInterval(function(){
                 if(mydiv1.offsetLeft==itarget)
                 {
                     clearInterval(timer);
                 }
                 else{
                     mydiv1.style.left=mydiv1.offsetLeft+speed+'px';
                 }
             }, 30);
         }
         
    </script>
</head>

<body>
    <div id="div1">
        <span>分享到</span>
    </div>
</body>
<html>


文件保存的编码不是 UTF-8.

如果确定文件是按utf-8编码保存的, 则看一下你浏览器当前是以什么编码显示的, 如果不是 utf-8 的话, 自己手工选择一下.

【热门文章】
【热门文章】