Am在chrome调试器中加载时收到错误myFunction未定义
Am receiving error myFunction not defined when loading in chrome debugger
Am在chrome调试器中收到未定义myFunction的通知。非常需要帮助。非常感谢。
<!DOCTYPE html>
<html>
<body>
<p>Click the button to loop through a block of as long as i is less than 10.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var text = "";
var i;
if (math.random > .5) i === "Heads"}
else { i === "tails"
};
while (i < 100) {
text += "<br>This Is " + i;
i++;
}
document.getElementById("demo").innerHTML = text;
}
</script>
</body>
</html>
使用您提供的代码,您还应该在控制台中看到另一个错误:
Uncaught SyntaxError: Unexpected token else
if (math.random > .5) i === "Heads"}
else { i === "tails"
};
应为:
if (Math.random() > .5) {
i = "Heads";
}
else {
i = "tails";
};
首先创建Javascript函数并调用它
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
var text = "";
var i;
if (math.random > .5) i === "Heads"}
else { i === "tails"
};
while (i < 100) {
text += "<br>This Is " + i;
i++;
}
document.getElementById("demo").innerHTML = text;
}
</script>
<p>Click the button to loop through a block of as long as i is less than 10.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
</body>
</html>
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- CKFinder 3为所选文件返回错误的URL
- 同位素库错误:未捕获错误无布局模式包装生产线8
- 铬:“;未捕获的语法错误:意外的标记:"
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- 相位器状态未捕获参考错误
- /undefined在我的404错误日志中多次出现
- 引用错误:未定义 myfunction
- 未捕获的语法错误:意外的标记<和未捕获的引用错误:未定义 myFunction
- Am在chrome调试器中加载时收到错误myFunction未定义
- TypeError: & # 39; MyClass.MyFunction不是函数'ES6 / node4的错误
- MyFunction()未捕获引用错误