未捕获语法错误意外结束输入(java脚本)

时间:2016-04-16 08:41:41

标签: javascript

最后一行显示错误

(function login() {
        FB.login(function(response) {
            if (response.status === 'connected') {
                getElementById('status').innerHTML = 'we are connected.';
            } else if (response.status === 'not authorized') {
                document.getElementById('status').innerHTML = 'we are not logged in.'
            } else {
                document.getElementById('status').innerHTML = 'you are not logged into facebook.';
            }
        });
    }

1 个答案:

答案 0 :(得分:0)

代码似乎存在多个问题

  1. 您第一次调用getElementById是一个错误。你应该在文档对象上调用它。
  2. 添加a);最后
  3. 您的代码看起来像

    (function login() {
        FB.login(function(response) {
            if (response.status === 'connected') {
                document.getElementById('status').innerHTML = 'we are connected.';
            } else if (response.status === 'not authorized') {
                document.getElementById('status').innerHTML = 'we are not logged in.'
            } else {
                document.getElementById('status').innerHTML = 'you are not logged into facebook.';
            }
        });
    });