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. 未捕獲的語法錯誤:缺少)後,從PHP
- 2. Javascript錯誤|未捕獲的語法錯誤:缺少)
- 3. 的JavaScript未捕獲的語法錯誤:缺少)
- 4. 未捕獲的語法錯誤:缺少)後的參數列表(用的.css())
- 5. 未捕獲的語法錯誤:缺少)後的參數列表/ JavaScript的
- 6. app.js:未捕獲的語法錯誤:缺少)後的參數列表
- 7. 離子未捕獲的語法錯誤:缺少)後仿真參數列表
- 8. 未捕獲的語法錯誤:缺少)後的參數列表....但它不是缺少
- 9. 語法錯誤:缺少)後cart.js
- 10. 未捕獲的語法錯誤:缺失)在參數
- 11. BASH語法錯誤 - [:缺少']」
- 12. 缺少語法錯誤; *前
- 13. JavaScript - 缺少語法錯誤
- 14. 未捕獲的異常:語法錯誤
- 15. 未捕獲的語法錯誤:在reactjs
- 16. 未捕獲的語法錯誤:
- 17. 在爭吵
- 18. 錯誤C2143:語法錯誤:缺少';' 'if'
- 19. 錯誤C2143:語法錯誤:缺少';'
- 20. 錯誤C2146:語法錯誤:缺少';'
- 21. 錯誤C2143:語法錯誤:缺少';'在'^'
- 22. RethinkDB錯誤:語法錯誤:缺少)後的參數列表
- 23. Python語法錯誤未被捕獲
- 24. 獲取錯誤:未捕獲語法錯誤:意外的令牌
- 25. 「未捕獲語法錯誤:缺少)後,參數列表」上簡單的報警功能
- 26. underscore.js未捕獲的語法錯誤:之後參數列表
- 27. Thymeleaf未捕獲的語法錯誤:之後參數列表
- 28. C語法 - 錯誤C2143:語法錯誤:在'*'之前缺少')'
- 29. 未捕獲的語法錯誤:意外的標識符錯誤
- 30. JQUERY:未捕獲的錯誤:語法錯誤#
請顯示[MCVE],解釋什麼行代碼有語法錯誤。 – 4castle