【问题标题】:Code block working in mozilla firefox but not in Chrome代码块在 mozilla firefox 中工作,但在 Chrome 中不工作
【发布时间】:2021-01-14 23:26:31
【问题描述】:

有谁知道为什么这个代码块可能在 Mozilla 中完美运行,而在 Chrome 中却完全不能运行?此代码块在 Mozilla Firefox 中完美生成和呈现,但在 Chrome 搜索引擎中完全没有。这开始于我将一些新代码放入从 x = -1 变量及以下开始的块中。

function displaySideBarLink( title, sectionname, anchorid) {

    let sidebar;

    if ($) {
        sidebar = $('#page-layout #record-sidebar .w3-container.menu-links');
    }

    if (sidebar) {
        // Create a link in the side bar navigation
        let sidebar_link = document.createElement("a");


        let section_title = title || sectionname;
        if (section_title) {
            sidebar_link.id = sectionname + "-sidebar";
            sidebar_link.className = "w3-bar-item";
            sidebar_link.href = '#' + anchorid;

            sidebar_link.title = section_title;
            sidebar_link.alt = section_title;
            sidebar_link.innerText = section_title;


            sidebar.append(sidebar_link);
        }

    }

    x = -1
    lastName = ""
    $("#panels-region .panel-heading").each(function () {
        x++
        console.log($(this))
        curName = $(this).attr("name")
        $('<a id="panels-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' + curName + '</a>').insertAfter("#panels-sidebar" + lastName.replace(/ |\//g, "_"))
        console.log($(this).attr("name"), lastName)
        lastName = "-" + curName
    })
    lastName = ""
    $("#graph-region .panel-heading h4").each(function () {
        try {
            x++
            console.log($(this).text())
            curName = $(this).text().replace("Collapse panelExpand panel", "")
            $('<a id="tree_viewers-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' + curName + '</a>').insertAfter("#tree_viewers-sidebar" + lastName.replace(/ |\//g, "_"))
            console.log($(this).attr("name"), lastName)
            lastName = "-" + curName
        } catch (e) {
        }
    })

    $(".menu-links a").css("padding", "0px 8px")

    $(".field-value").each(function () {
        $(this).html($(this).text())
    })
    $("#tables-content td").each(function () {
        $(this).html($(this).text())
    })
    $(".panel-body").css("background-color", "white")
    $("#panels-region .panel-wrapper .panel-default").css("background-color", "white")
}

【问题讨论】:

  • “Chrome 搜索引擎”???
  • 那么开发者控制台有错误吗?是否有任何控制台行执行?
  • 加载资源失败:服务器响应状态为 404 (Not Found) views.js:60 获取用户权限失败,url = /query/web/api/v1/user跨度>
  • Uncaught TypeError: this.getPermissions is not a function at Object. (views.js:63) at fire (jquery.js:3099) at Object.fireWith [as rejectWith] (jquery .js:3211) 在完成 (jquery.js:8266) 在 XMLHttpRequest. (jquery.js:8605)
  • jquery.js:8561 [弃用] 主线程上的同步 XMLHttpRequest 已弃用,因为它会对最终用户的体验产生不利影响。如需更多帮助,请查看xhr.spec.whatwg.org。发送@jquery.js:8561 undefined.svg:1 加载资源失败:服务器响应状态为404(未找到)

标签: javascript node.js google-chrome firefox


【解决方案1】:
function getRecordUI( alias, type, id, viewtype, version ) {

    // Get record model from Data Model Registry
    if ( type ) {
        getJSONUIModel( type,
            function ( data ) {
                displayRecordSections( alias, type, id, version, viewtype, data );
            },
            function (error) {
                console.log("Error getting UI model for type " + type);
                console.log(error);
                displayRecordSections( alias, type, id, version, viewtype, null );
            });
    } else {
        displayRecordSections( alias, type, id, version, viewtype, null );
    }
    let x = -1;
    lastName = "";
    $("#panels-region .panel-heading").each(function () {
        x++

        console.log($(this))
        let curName = $(this).attr("name")
        $('<a id="panels-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' + curName + '</a>').insertAfter("#panels-sidebar" + lastName.replace(/ |\//g, "_"))
        console.log($(this).attr("name"), lastName)
        lastName = "-" + curName
    })

    $("#graph-region .panel-heading h4").each(function () {
        x++
        let x = -1;
        console.log($(this).text())
        let curName = $(this).text().replace("Collapse panelExpand panel", "")
        $('<a id="tree_viewers-sidebar-' + curName.replace(/ |\//g, "_") + '" class="w3-bar-item" href="#panel-' + x + '-header" title="' + curName.replace(/ |\//g, "_") + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' + curName + '</a>').insertAfter("#tree_viewers-sidebar" + lastName.replace(/ |\//g, "_"))
        console.log($(this).attr("name"), lastName)
        lastName = "-" + curName
    })

    $(".menu-links a").css("padding", "0px 8px")
    $(".panel-body").css("background-color", "white")
    $("#panels-region .panel-wrapper .panel-default").css("background-color", "white")

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-20
    • 2016-04-18
    • 2017-05-10
    相关资源
    最近更新 更多