我得到一个:
ExternalError: TypeError: Cannot read property 'innerHTML' of null on line 2
在此代码的控制台日志中...
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.0/jquery.js"></script>
<script src="http://www.skulpt.org/static/skulpt.min.js" type="text/javascript"></script>
<script src="http://www.skulpt.org/static/skulpt-stdlib.js" type="text/javascript"></script>
<title>Python Coding Area</title>
<script type='text/javascript'>
function outf(text) {
var mypre = document.getElementById("output");
mypre.innerHTML = mypre.innerHTML + text;
}
function builtinRead(x) {
if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)
throw "File not found: '" + x + "'";
return Sk.builtinFiles["files"][x];
}
function runit() {
var prog = document.getElementById("textbox").value;
var mypre = document.getElementById("dynamicframe");
mypre.innerHTML = '';
Sk.pre = "output";
Sk.configure({output:outf, read:builtinRead});
(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'canvas';
var myPromise = Sk.misceval.asyncToPromise(function() {
return Sk.importMainWithBody("<stdin>", false, prog, true);
});
myPromise.then(function(mod) {
console.log('success');
},
function(err) {
console.log(err.toString());
});
}
</script>
</head>
<body style="font-family:Raleway !important;">
<textarea id="textbox" cols="50" rows="10"></textarea><br />
<button type="button" onclick="runit()">Run</button>
</form>
<pre id="dynamicframe" ></pre>
<div id="canvas"></div>
</body>
</html>
当我单击运行按钮以使用 skulpt 运行 python 代码时。在这种情况下使用 skulpt 有问题吗?我从 skulpt 网站 (skulpt.org) 获取了一些代码,并对其进行了一些修改。为什么我会收到错误,我该如何阻止它?