小编Kat*_*Man的帖子

为什么在调试时在画布上绘制图像,而不是在运行时?

我正在学习HTML5和Javascript,我正试图在画布上绘制图像.如果我在打破下面标记的行后单步执行代码,我有以下代码绘制图像.如果我不调试那么根本不绘制图像.我究竟做错了什么?Firefox 10与FireBug 1.9.

请注意,虽然有一个循环来处理多个图像,但我只选择了一个.我想如果一个人不工作,那么一百个也不会工作.;-)

<!DOCTYPE html>
<html>
<body>
    <input type="file" id="files" name="files[]" multiple />
    <canvas id="picCanvas" />
    <script>
        function handleFileSelect(evt) {
            var files = evt.target.files;

            // Loop through the FileList and render images
            for (var i = 0, f; f = files[i]; i++) {

                // Only process image files.
                if (!f.type.match('image.*')) {
                    continue;
                }

                var reader = new FileReader();

                // Closure to capture the file information.
                reader.onload = (function (theFile) {
                    return function (e) {
                        var img = document.createElement('img'); // …
Run Code Online (Sandbox Code Playgroud)

javascript firefox html5 firebug

1
推荐指数
1
解决办法
660
查看次数

标签 统计

firebug ×1

firefox ×1

html5 ×1

javascript ×1