Javascript 代码在JSFIDLE站点中运行良好,但在我的桌面工具上无法运行

Javascript 代码在JSFIDLE站点中运行良好,但在我的桌面工具上无法运行,javascript,html,jsfiddle,Javascript,Html,Jsfiddle,我用JAVASCRIPT+HTML5设计了一个网页。它在JSFIDLE中运行良好,但当我在记事本或W3S站点中尝试它时,它并没有运行。我的代码有什么问题 我的html代码是 <head> <style> #scroll-content2 { height:100%; width:100%; background-color:blue; } .images { height:60px; width:60px; } .table2 { width:300px;

我用JAVASCRIPT+HTML5设计了一个网页。它在JSFIDLE中运行良好,但当我在记事本或W3S站点中尝试它时,它并没有运行。我的代码有什么问题

我的html代码是

<head>
<style>
#scroll-content2  { height:100%; width:100%; background-color:blue;  }
.images  {  height:60px; width:60px;  }
.table2  {  width:300px;  }
.c2  {  height:300px; background-color:lightblue;   }
</style>
</head>
<body><section id="scroll-content2"></section></body>

#滚动内容2{高度:100%;宽度:100%;背景色:蓝色;}
.图像{高度:60px;宽度:60px;}
.table2{宽度:300px;}
.c2{高度:300px;背景色:浅蓝色;}
我的javascript是;(我把这个放在html文件的一节中)


变量a=[‘选项a’、‘选项b’、‘选项c’、‘选项d’、‘选项e’、‘选项f’];
VarB=[‘好’、‘好’、‘坏’、‘优秀’、‘平均’];
函数init(){
函数img(){
var image=document.createElement('image');
image.className='images';
image.src=https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWUb6zXlz-7lTc53ACFi_kCg0Vojxha2Hk00602if3wOZ3my9j6A';
}
返回图像;}
window.onload=img()
对于(var i=0;i而言,这是有效的:

var a = ['option a', 'option b', 'option c', 'option d', 'option e', 'option f'];
var b = ['good', 'ok', 'bad', 'excellent', 'average'];

function init() {
    for (var i = 0; i < a.length; i++) {
        var ele = document.getElementById('scroll-content2');
        var table = document.createElement('table');
        table.className = 'table2';
        var tr = document.createElement('tr');
        tr.className = 'c2';
        var td = document.createElement('td');
        var txt4 = document.createTextNode(i + 1 + "." + " ");
        var txt = document.createTextNode(a[i]);
        td.appendChild(txt4);
        td.appendChild(txt);

        for (var j = 0; j < b.length; j++) {
            var divi = document.createElement('div');
            divi.className = 'divi';
            var txt2 = document.createTextNode(b[j]);
            divi.appendChild(img());
            divi.appendChild(txt2);
            td.appendChild(divi);
        }
        tr.appendChild(td);
        table.appendChild(tr);
        ele.appendChild(table);
    }
}

function img() {
    var image = document.createElement('image');
    image.className = 'images';
    image.src = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWUb6zXlz-7lTc53ACFi_kCg0Vojxha2Hk00602if3wOZ3my9j6A';
    return image;
}

window.onload = init();
var a=['option a','option b','option c','option d','option e','option f'];
var b=[‘良好’、‘正常’、‘不良’、‘优秀’、‘平均’];
函数init(){
对于(变量i=0;i
var a = ['option a', 'option b', 'option c', 'option d', 'option e', 'option f'];
var b = ['good', 'ok', 'bad', 'excellent', 'average'];

function init() {
    for (var i = 0; i < a.length; i++) {
        var ele = document.getElementById('scroll-content2');
        var table = document.createElement('table');
        table.className = 'table2';
        var tr = document.createElement('tr');
        tr.className = 'c2';
        var td = document.createElement('td');
        var txt4 = document.createTextNode(i + 1 + "." + " ");
        var txt = document.createTextNode(a[i]);
        td.appendChild(txt4);
        td.appendChild(txt);

        for (var j = 0; j < b.length; j++) {
            var divi = document.createElement('div');
            divi.className = 'divi';
            var txt2 = document.createTextNode(b[j]);
            divi.appendChild(img());
            divi.appendChild(txt2);
            td.appendChild(divi);
        }
        tr.appendChild(td);
        table.appendChild(tr);
        ele.appendChild(table);
    }
}

function img() {
    var image = document.createElement('image');
    image.className = 'images';
    image.src = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQWUb6zXlz-7lTc53ACFi_kCg0Vojxha2Hk00602if3wOZ3my9j6A';
    return image;
}

window.onload = init();