具有全局变量的Javascript意外标识符

时间:2013-10-27 05:18:55

标签: javascript html global-variables

我的页面上有这个代码:

<script type="text/javascript">
    var timeFinal = 3;
    function timeZone(timeBegin,timeEnd) {
        var tz = new Date();
        tz = tz.getTimezoneOffset() / 60;
        timeBegin = timeBegin - tz;
        if (timeBegin <= -1) {
            timeBegin = 24 - timeBegin;
        }
        else {
        }   
        timeFinal = timeBegin + ":" timeEnd;
    }

    function FileModifDate() {
        var dateModif = document.lastModified;
        var startTimeModif = dateModif.indexOf(":") - 2;
        var time = dateModif.substring(startTimeModif, dateModif.length - 3);
        var timeBegin = time.substring(0, 1);
        var timeEnd = time.substring(3, 4);
        var date = dateModif.substring(0, 6);
        date = date.substring(3, 4) + "/" + date.substring(0, 1) + "/" + date.substring(8, 9);
        timeZone(timeBegin,timeEnd);
        dateModif = timeFinal + " " + date;
        document.getElementById('ModifDate').innerHTMl = dateModif;

    }
</script>

但由于某种原因发生错误。它表示第21行中的意外标识符:

    timeFinal = timeBegin + ":" timeEnd;

有人可以告诉我出了什么问题吗?

1 个答案:

答案 0 :(得分:2)

timeFinal = timeBegin + ":" + timeEnd;

---------------------------------------------- ^你错过了+这里

修正了代码here