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