javascript - 代码块在 mozilla firefox 中工作,但在 Chrome 中不工作
问题描述
有谁知道为什么这个代码块在 Mozilla Perfectly 中运行良好,而在 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, "_") + '"> ' + 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, "_") + '"> ' + 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")
}
解决方案
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, "_") + '"> ' + 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, "_") + '"> ' + 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")
}
推荐阅读
- protractor - 如何在 grunt-protractor-runner v5、protractor v4.0.14 和 node v8.13 中配置调试
- mysql - mysqldump 与 php 导出单个表
- django - Django - 组织/服务主要是静态网站的最佳方式?
- ios - 使用关系附加核心数据实体
- bash - 如何在函数中停止“* .h”的 Bash 扩展?
- javascript - 捕获部分 JSON 响应并保存到变量中?
- php - PHP 标头问题
- concatenation - 谷歌表格 - 如何连接满足条件的单元格
- python - 绘制索引稀疏的时间序列时如何避免matplotlib中的时间间隔?
- c# - 为什么命名空间的一部分算作命名空间