Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery脚本没有';无法在Internet Explorer中运行(第1行出现语法错误)_Javascript_Jquery_Html_Internet Explorer_Syntax Error - Fatal编程技术网

Javascript jQuery脚本没有';无法在Internet Explorer中运行(第1行出现语法错误)

Javascript jQuery脚本没有';无法在Internet Explorer中运行(第1行出现语法错误),javascript,jquery,html,internet-explorer,syntax-error,Javascript,Jquery,Html,Internet Explorer,Syntax Error,我正在为一个新项目开发一个响应性html模型,它包含一些jquery脚本,可以在每个浏览器上完美运行。。。除了InternetExplorer(我目前正在IE9上测试) 我很自然地检查了IE的javascript控制台,它给了我以下错误消息: SCRIPT1002: Syntax error scripts.js, line 1 character 1 我完全不知道这是从哪里来的,因为DreamWeaver和Komodo Edit都没有检测到任何错误 实体模型在以下地址联机: 下面是导致错误

我正在为一个新项目开发一个响应性html模型,它包含一些jquery脚本,可以在每个浏览器上完美运行。。。除了InternetExplorer(我目前正在IE9上测试)

我很自然地检查了IE的javascript控制台,它给了我以下错误消息:

SCRIPT1002: Syntax error 
scripts.js, line 1 character 1
我完全不知道这是从哪里来的,因为DreamWeaver和Komodo Edit都没有检测到任何错误

实体模型在以下地址联机:

下面是导致错误的脚本:

const visible = "visible";
const hidden = "hidden";
const open = "open";

$(document).ready(function(e) {
    $(".collapsible_container .links").hide();
    showHomeMenu();

    $("#home_link").click(showHomeMenu);

    $("#admin_link").click(showAdminMenu);

    $("#left_menu .links a").click(function() {
        $("#left_menu .links").slideUp("fast");
        $("#left_menu .collapsible_container").removeClass(open);
    });

    $("section .section_header").click(function() {
        var sectionContent = $(this).parent("section").children(".section_content");
        var sectionHeader = $(this);
        toggleSection(sectionHeader, sectionContent);
    });
});

function toggleSection(sectionHeader, sectionContent) {
    var isOpen = sectionHeader.hasClass(open);

    if (isOpen) {
        sectionContent.slideUp("slow", function() {
            sectionHeader.removeClass(open);
        });
    } else {
        sectionContent.slideDown("slow");
        sectionHeader.addClass(open);
    }
}

function setLeftMenuHeight() {
    var visibleChildren = $("#left_menu .collapsible").not(".hidden")

    if (visibleChildren.length > 8) {
        $("aside").removeClass("h100").addClass("h150");
    } else if (visibleChildren.length > 4) {
        $("aside").removeClass("h150").addClass("h100");
    } else {
        $("aside").removeClass("h100").removeClass("h150");
    }
}

function showHomeMenu() {
    $("#left_menu .admin").addClass("hidden");
    $("#left_menu .home").removeClass("hidden");
    $("#left_menu .admin h3 a").unbind("click");
    setLeftMenuHeight();

    $("#left_menu .home h3 a").click(function() {
        var current = $(this).parent("h3").parent(".collapsible_container").children(".links")
        animateMenu(current);
    });
}

function showAdminMenu() {
    $("#left_menu .home").addClass("hidden");
    $("#left_menu .admin").removeClass("hidden");
    $("#left_menu .home h3 a").unbind("click");
    setLeftMenuHeight();

    $("#left_menu .admin h3 a").click(function() {
        var current = $(this).parent("h3").parent(".collapsible_container").children(".links")
        animateMenu(current);
    });
}

function animateMenu(current) {
    var isVisible = current.hasClass(visible)       

    $("#left_menu .links").removeClass(visible);
    $("#left_menu .collapsible_container").removeClass(open);

    $.when($("#left_menu .links").slideUp("fast")).then(function() {
        if (!isVisible) {
            current.slideDown("fast");
            current.addClass(visible);
            current.parent(".collapsible_container").addClass(open);
        } else {
            current.parent(".collapsible_container").removeClass(open);
        }
    });
}
你知道这个问题吗?我对jQuery很陌生,在这里我完全不懂


注意:我在版本1.11.0中使用jquery,以防万一。

尽管现代版本的IE(6-10)不支持它。 只有基于gecko的浏览器和Chrome支持它

现在javascript中的变量使用
var
,而不是
const
来避免这个问题

更改此项:

const visible = "visible";
const hidden = "hidden";
const open = "open";
为此:

var visible = "visible";
var hidden = "hidden";
var open = "open";

正在尝试将常量更改为var

var visible = "visible";
var hidden = "hidden";
var open = "open";

const
在IE6-10中不受支持
const
是一项新功能,IE尚未支持。IE11支持它,请注意,chrome也支持它;)无论如何,相关信息+1