Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 views
in Technique[技术] by (71.8m points)

这段代码为什么报错啊?

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>满天飞舞的雪花</title>
</head>
<body bgcolor="#000000">
<script language="javascript">
    var num = 15; 
    x = new Array(); 
    y = new Array();
    doc_width = document.body.clientWidth;
    doc_height = document.body.clientHeight;

    for (i = 0; i < num; i++) {
        x[i] = Math.random()*(doc_width-30)+10; 
        y[i] = Math.random()*doc_height;
        str = "<img src='../assets/img/coupon_ico.png' style='position:absolute;";
        str += "top:" + y[i] + ";left:" + x[i] + "'id='dot" + i + "'>";
        document.write(str);
    }
    function snow(){
        for (i = 0; i < num; i++){
            x[i]+=Math.random()*3;
            x[i]-=Math.random()*3;
            y[i]++;
            if(y[i]>doc_height)y[i] = -20;
            document.all["dot"+i].style.pixelTop = y[i];
            document.all["dot"+i].style.pixelLeft = x[i];
        }
        setTimeout("snow()",10);
    }
    snow();
</script>
</body>
</html>

clipboard.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

第一个 TypeError 是安装的浏览器插件中的代码报错,跟你的代码没关系,

第二个 404错误,是没有 favicon 图标,你看浏览器标签页最上面,title的左边是不是有个网站的小图标,就是这东东,自己写测试demo不加也没多大事,具体怎么加你搜这个关键词,大概就是图片放同级目录或者根目录,在页面里用link标签引入


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...