参数list3之后的Uncaught SyntaxError:missing)

时间:2017-08-31 05:29:13

标签: javascript

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();

5 个答案:

答案 0 :(得分:2)

function showAnotherMessage() {
    alert("Hi " + yourName + ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");
}
你错过了一个" +"在你的警报中。

答案 1 :(得分: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;

答案 2 :(得分:0)

您在警报连接中缺少+alert("Hi " + yourName + ".\nThis is an alert message is no longer defined\nin the HTML but in a JavaScript file");

答案 3 :(得分: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();

答案 4 :(得分:0)

如果问题仍然存在,那么它与调用函数

有关
 clickme.onclick = showAnotherMessage;
// instead use below
 clickme.onclick = showAnotherMessage();