var yourName; //global variable accessible to all functions
function showAnotherMessage() {
alert("Hi " + yourName ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");
}
function init() {
yourName = Prompt("Hi. Enter your name.\nWhen the browser window is first loaded\nthe function containing this prompt window is called.", "Your name");
clickme = document.getElementById("clickme");
clickme.onclick = showAnotherMessage;
}
window.onload = init();
0
A
回答
0
通到window.onload
不是结果的功能,但功能的参考,并添加警报的消息中错过了+
alert("Hi " + yourName + ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");
参考
window.onload = init;
+0
虽然这不会是一个语法错误。 – 4castle
+0
必须是别的东西!因为错误仍然存在 –
2
function showAnotherMessage() {
alert("Hi " + yourName + ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");
}
你错过了“+”的提醒。
0
您在提醒并置中缺少+
。 alert("Hi " + yourName + ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");
0
您错过了一个连接。 提示应该是小写。
var yourName; //global variable accessible to all functions
function showAnotherMessage() {
alert("Hi " + yourName + ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");
}
function init() {
yourName = prompt("Hi. Enter your name.\nWhen the browser window is first loaded\nthe function containing this prompt window is called.", "Your name");
clickme = document.getElementById("clickme");
clickme.onclick = showAnotherMessage;
}
window.onload = init();
0
如果问题仍然存在,,则与调用函数
clickme.onclick = showAnotherMessage;
// instead use below
clickme.onclick = showAnotherMessage();
相关问题
- 1. 的JavaScript未捕获的语法错误:缺少)
- 2. 未捕获的语法错误:缺少)后的参数列表(用的.css())
- 3. app.js:未捕获的语法错误:缺少)后的参数列表
- 4. 离子未捕获的语法错误:缺少)后仿真参数列表
- 5. 未捕获的语法错误:缺少)后的参数列表....但它不是缺少
- 6. 语法错误:缺少)后cart.js
- 7. 未捕获的语法错误:缺失)在参数
- 8. JavaScript - 缺少语法错误
- 9. 缺少语法错误; *前
- 10. BASH语法错误 - [:缺少']”
- 11. 未捕获的语法错误:在reactjs
- 12. 未捕获的异常:语法错误
- 13. 未捕获的语法错误:
- 14. 错误C2143:语法错误:缺少';' 'if'
- 15. 错误C2143:语法错误:缺少';'在'^'
- 16. Python语法错误未被捕获
- 17. “未捕获语法错误:缺少)后,参数列表”上简单的报警功能
- 18. underscore.js未捕获的语法错误:之后参数列表
- 19. C语法 - 错误C2143:语法错误:在'*'之前缺少')'
- 20. JQUERY:未捕获的错误:语法错误#
- 21. 未捕获的语法错误:之后参数列表丢失)JavaScript错误
- 22. 语法错误(缺少操作员)
- 23. 语法错误:缺少;在JSONResponse
- 24. 语法错误:缺少';'标识
- 25. Awesomium C++:语法错误:缺少';'之前'*'
- 26. 语法错误:缺少;声明
- 27. 语法错误:缺少;陈述前?
- 28. 语法错误:缺少';'之前'。'
- 29. Makefile语法错误。缺少分隔符
- 30. 语法错误(缺少操作员)
请显示[MCVE],解释什么行代码有语法错误。 – 4castle