- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 javascript 创建一个巨大的数组...它有 4 层深,有很多元素长。我在运行时使用 php 创建它,以便页面上的所有内容都能顺利运行,无需执行任何查询。
但是,现在,我的数组遇到了一些问题,我的 html 文件没有看到数组后面列出的 javascript 函数。通过测试,我已经缩短了数组并使其能够工作,但我一生都无法弄清楚为什么它会以完整形式 chop 脚本的其余部分。
如果有任何答案可以告诉我,我将不胜感激A.如何使用Firebug查找问题(我对Firebug很陌生)或者B. 告诉我#$%^ 问题是什么!
我将在下面列出我的整个脚本(php 的输出)。有问题的数组是“inventoryNames”。我已经检查过问题是否出在括号的数量上,但我现在 99% 肯定是这个问题。如果我将其注释掉,一切都会正常。谢谢
<script type="text/javascript">
var inventoryNames =
Array(
Array(
Array(
Array("AC/DC", "Back in Black", "36", "VG++", "12", ""),
Array("AC/DC", "Back in Black", "37", "VG", "8", "")
),
Array(
Array("AC/DC", "Highway to Hell", "30", "VG++", "10", ""),
Array("AC/DC", "Highway to Hell", "38", "VG", "5", ""),
Array("AC/DC", "Highway to Hell", "35", "NM", "16", ""),
Array("AC/DC", "Highway to Hell", "39", "NM", "14", "")
)
),
Array(
Array(
Array("Al Green", "Call Me", "40", "G", "5", ""),
Array("Al Green", "Call Me", "31", "NM", "15", "")
),
Array(
Array("Al Green", "Let's Stay Together", "32", "NM", "12", ""),
Array("Al Green", "Let's Stay Together", "33", "VG++", "10", ""),
Array("Al Green", "Let's Stay Together", "34", "VG", "8", "")
)
),
Array(
Array(
Array("B.B. King", "Confessin' the Blues", "45", "VG++", "9", ""),
Array("B.B. King", "Confessin' the Blues", "42", "NM", "35", "")
),
Array(
Array("B.B. King", "Lucille", "43", "VG++", "14", "")
),
Array(
Array("B.B. King", "Singin' the Blues", "41", "NM", "16", "")
),
Array(
Array("B.B. King", "Sings Spirituals", "44", "VG++", "10", "")
)
),
Array(
Array(
Array("Bad Company", "Bad Company", "12", "G", "2", ""),
Array("Bad Company", "Bad Company", "13", "M", "38", "1st Edition"),
Array("Bad Company", "Bad Company", "14", "VG+", "8", ""),
Array("Bad Company", "Bad Company", "3", "VG++", "13", "")
)
),
Array(
Array(
Array("Bob Dylan", "Another Side of Bob Dylan", "48", "VG++", "20", "")
),
Array(
Array("Bob Dylan", "Blonde on Blonde", "50", "M", "35", "")
),
Array(
Array("Bob Dylan", "Highway 61 Revisited", "49", "NM", "25", "")
),
Array(
Array("Bob Dylan", "The Freewheelin' Bob Dylan", "46", "VG++", "13", "")
),
Array(
Array("Bob Dylan", "The Times They Are A-Changin'", "47", "NM", "25", "")
)
),
Array(
Array(
Array("Boston", "Boston", "52", "VG++", "12", ""),
Array("Boston", "Boston", "53", "VG++", "10", ""),
Array("Boston", "Boston", "51", "VG", "7", ""),
Array("Boston", "Boston", "23", "VG", "6", "")
)
),
Array(
Array(
Array("Charlie Parker", "Jazz at Massey Hall", "54", "NM", "42", "")
)
),
Array(
Array(
Array("Creedence Clearwater Revival", "Green River", "56", "VG++", "13", ""),
Array("Creedence Clearwater Revival", "Green River", "57", "NM", "16", ""),
Array("Creedence Clearwater Revival", "Green River", "55", "VG+", "10", "")
),
Array(
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "60", "NM", "15", ""),
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "114", "NM", "16", ""),
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "58", "G", "5", ""),
Array("Creedence Clearwater Revival", "Willy and the Poor Boys", "59", "VG", "7", "")
)
),
Array(
Array(
Array("Dave Brubeck", "Time Out", "61", "NM", "18", ""),
Array("Dave Brubeck", "Time Out", "62", "VG+", "10", "")
)
),
Array(
Array(
Array("David Allan Coe", "Longhaired Redneck", "63", "VG+", "8", "")
),
Array(
Array("David Allan Coe", "Rides Again", "64", "VG+", "6", ""),
Array("David Allan Coe", "Rides Again", "65", "NM", "10", "")
)
),
Array(
Array(
Array("David Bowie", "Hunky Dory", "18", "NM", "40", "Rare!")
),
Array(
Array("David Bowie", "Ziggy Stardust and the Spiders From Mars", "21", "VG++", "15", "")
)
),
Array(
Array(
Array("Earth, Wind & Fire", "Earth, Wind & Fire", "67", "VG+", "10", "")
),
Array(
Array("Earth, Wind & Fire", "That's the Way of the World", "66", "NM", "15", "")
)
),
Array(
Array(
Array("Foghat", "Energized", "68", "NM", "10", ""),
Array("Foghat", "Energized", "2", "M", "2", "")
)
),
Array(
Array(
Array("George Harrison", "All Things Must Pass", "69", "NM", "35", ""),
Array("George Harrison", "All Things Must Pass", "1", "M", "2", "")
)
),
Array(
Array(
Array("Guns N Roses", "Appetite for Destruction", "70", "NM", "20", "")
)
),
Array(
Array(
Array("Hank Williams", "Hank Williams Sings", "29", "M", "55", ""),
Array("Hank Williams", "Hank Williams Sings", "71", "NM", "70", "")
)
),
Array(
Array(
Array("Herbie Hancock", "Empyrean Isles", "72", "VG++", "10", "")
),
Array(
Array("Herbie Hancock", "Head Hunters", "74", "VG++", "13", "")
),
Array(
Array("Herbie Hancock", "Maiden Voyahe", "73", "VG++", "13", "")
)
),
Array(
Array(
Array("Huey Lewis & the News", "Sports", "76", "VG+", "3", ""),
Array("Huey Lewis & the News", "Sports", "77", "VG", "2", ""),
Array("Huey Lewis & the News", "Sports", "75", "NM", "8", "")
)
),
Array(
Array(
Array("Its a Beautiful Day", "Its a Beautiful Day", "20", "VG++", "10", "")
)
),
Array(
Array(
Array("James Brown", "Prisoner of Love", "78", "VG++", "18", "")
)
),
Array(
Array(
Array("Jimi Hendrix", "Are You Experienced", "22", "VG+", "12", "")
)
),
Array(
Array(
Array("John Lee Hooker", "John Lee Hooker Plays and Sings the Blues", "81", "VG++", "15", "")
),
Array(
Array("John Lee Hooker", "Travelin'", "80", "VG++", "15", ""),
Array("John Lee Hooker", "Travelin'", "82", "VG+", "15", ""),
Array("John Lee Hooker", "Travelin'", "79", "VG++", "20", "")
)
),
Array(
Array(
Array("Mazaak", "Fat Man Suicide", "25", "M", "200", "Includes classics like "Cream Green and Beans" and the title track "Fat Man Suicide"!")
)
),
Array(
Array(
Array("Miles Davis", "Bitches Brew", "85", "NM", "30", "")
),
Array(
Array("Miles Davis", "Kind of Blue", "84", "VG+", "15", ""),
Array("Miles Davis", "Kind of Blue", "83", "VG", "10", "")
),
Array(
Array("Miles Davis", "Miles Ahead", "87", "NM", "15", "")
),
Array(
Array("Miles Davis", "Round About Midnight", "86", "NM", "45", "")
),
Array(
Array("Miles Davis", "Star People", "88", "M", "15", "")
)
),
Array(
Array(
Array("Motley Crue", "Theatre of Pain", "4", "VG", "5", ""),
Array("Motley Crue", "Theatre of Pain", "16", "VG", "5", "")
)
),
Array(
Array(
Array("Muddy Waters", "At Newport", "89", "VG+", "10", "")
),
Array(
Array("Muddy Waters", "Hard Again", "90", "VG++", "15", "")
)
),
Array(
Array(
Array("Otis Redding", "In Person at the Whisky a Go Go", "28", "VG++", "20", "")
),
Array(
Array("Otis Redding", "Otis Blue", "92", "VG+", "12", "")
),
Array(
Array("Otis Redding", "The Dock of the Bay", "91", "VG++", "20", "")
)
),
Array(
Array(
Array("Ozzy Osbourne", "Bark at the Moon", "95", "VG++", "15", "")
),
Array(
Array("Ozzy Osbourne", "Blizzard of Ozz", "93", "VG++", "10", ""),
Array("Ozzy Osbourne", "Blizzard of Ozz", "94", "VG++", "12", "")
)
),
Array(
Array(
Array("Parliament", "Mothership Connection", "96", "VG", "8", "")
),
Array(
Array("Parliament", "Motor Booty Affair", "97", "NM", "12", "")
)
),
Array(
Array(
Array("Pink Floyd", "Wish You Were Here", "15", "NM", "17", "")
)
),
Array(
Array(
Array("Sly & the Family Stone", "Stand!", "100", "NM", "20", ""),
Array("Sly & the Family Stone", "Stand!", "98", "VG", "8", ""),
Array("Sly & the Family Stone", "Stand!", "99", "VG++", "15", "")
)
),
Array(
Array(
Array("Taj Mahal", "Giant Step", "6", "VG+", "13", ""),
Array("Taj Mahal", "Giant Step", "19", "VG+", "10", "")
)
),
Array(
Array(
Array("Talking Heads", "Remain in Light", "101", "VG++", "15", ""),
Array("Talking Heads", "Remain in Light", "102", "VG+", "10", ""),
Array("Talking Heads", "Remain in Light", "103", "NM", "20", "")
),
Array(
Array("Talking Heads", "Talking Heads 77", "104", "NM", "25", "")
)
),
Array(
Array(
Array("The Allman Brothers Band", "At Fillmore East", "105", "VG++", "15", ""),
Array("The Allman Brothers Band", "At Fillmore East", "106", "VG++", "15", ""),
Array("The Allman Brothers Band", "At Fillmore East", "11", "NM", "16", "")
),
Array(
Array("The Allman Brothers Band", "Eat a Peach", "8", "G", "3", ""),
Array("The Allman Brothers Band", "Eat a Peach", "9", "VG", "8", ""),
Array("The Allman Brothers Band", "Eat a Peach", "10", "M", "20", "")
)
),
Array(
Array(
Array("The Beatles", "Rubber Soul", "24", "M", "1.93", "")
),
Array(
Array("The Beatles", "Sgt. Pepper's Lonely Hearts Club Band", "5", "VG+", "15", ""),
Array("The Beatles", "Sgt. Pepper's Lonely Hearts Club Band", "27", "VG++", "20", "")
)
),
Array(
Array(
Array("The Mothers of Invention", "Freak Out!", "17", "NM", "20", "")
)
),
Array(
Array(
Array("The Rolling Stones", "Exile on Main Street", "107", "NM", "25", "")
),
Array(
Array("The Rolling Stones", "Let It Bleed", "7", "M", "12", "")
)
),
Array(
Array(
Array("Thelonious Monk", "Brilliant Corners", "108", "VG++", "30", ""),
Array("Thelonious Monk", "Brilliant Corners", "109", "M", "60", "")
),
Array(
Array("Thelonious Monk", "Monk's Dream", "110", "VG++", "19", ""),
Array("Thelonious Monk", "Monk's Dream", "26", "NM", "35", "")
)
),
Array(
Array(
Array("Willie Nelson", "Phases and Stages", "113", "VG++", "12", "")
),
Array(
Array("Willie Nelson", "Red Headed Stranger", "112", "VG++", "11", ""),
Array("Willie Nelson", "Red Headed Stranger", "111", "VG++", "10", "")
)
)
);
var albumNames = Array(Array("Highway to Hell", "Back in Black"), Array("Call Me", "Let's Stay Together"), Array("Singin' the Blues", "Confessin' the Blues", "Sings Spirituals", "Lucille", "Live at the Regal"), Array("Bad Company"), Array("The Freewheelin' Bob Dylan", "The Times They Are A-Changin'", "Another Side of Bob Dylan", "Bringing It All Back Home", "Highway 61 Revisited", "Blonde on Blonde", "John Wesley Harding", "Nashville Skyline", "Self Portrait", "New Morning", "Blood on the Tracks"), Array("Boston"), Array("Jazz at Massey Hall"), Array("Green River", "Cosmos Factory", "Willy and the Poor Boys"), Array("Time Out", "The Dave Brubeck Quartet at Carnegie Hall"), Array("Longhaired Redneck", "Rides Again"), Array("Ziggy Stardust and the Spiders From Mars", "Hunky Dory"), Array("That's the Way of the World", "Earth, Wind & Fire"), Array("Energized"), Array("All Things Must Pass"), Array("Appetite for Destruction"), Array("Hank Williams Sings"), Array("Empyrean Isles", "Maiden Voyahe", "Head Hunters", "Sextant", "Crossings"), Array("Sports", "Picture This"), Array("Its a Beautiful Day"), Array("Prisoner of Love"), Array("Are You Experienced"), Array("Travelin'", "John Lee Hooker Plays and Sings the Blues"), Array("Fat Man Suicide"), Array("Round About Midnight", "Miles Ahead", "Kind of Blue", "Bitches Brew", "Star People"), Array("Theatre of Pain"), Array("At Newport", "Folk Singer", "Brass and the Blues", "Hard Again"), Array("The Dock of the Bay", "Otis Blue", "In Person at the Whisky a Go Go"), Array("Blizzard of Ozz", "Bark at the Moon"), Array("Mothership Connection", "Motor Booty Affair"), Array("Wish You Were Here"), Array("Look What the Cat Dragged In"), Array("The Genius of Ray Charles", "Modern Sounds in Country and Western Music", "The Genius Sings the Blues"), Array("Stand!", "Fresh"), Array("Giant Step", "Taj Mahal", "Happy Just to Be Like I Am", "Music Keeps Me Together"), Array("Remain in Light", "Talking Heads 77", "Speaking in Tongues"), Array("Eat a Peach", "At Fillmore East"), Array("Please Please Me", "A Hard Day's Night", "Help!", "Rubber Soul", "Revolver", "Sgt. Pepper's Lonely Hearts Club Band", "Magical Mystery Tour", "The Beatles (White Album)", "Abbey Road", "Let It Be"), Array("Freak Out!"), Array("Exile on Main Street", "Big Hits (High Tide and Green Grass)", "Let It Bleed"), Array("Brilliant Corners", "Evidence", "Monk's Dream"), Array("Red Headed Stranger", "Yesterday's Wine", "Phases and Stages", "The Sound in Your Mind"));
function byId(id){
return document.getElementById ? document.getElementById(id) : document.all[id];
}
function populateAlbums(index) {
var i = byId('albumSelect').options.length;
for (; i>=0; i--) {
byId('albumSelect').remove(i);
}
var artistAlbums = albumNames[index];
for (i = 0; i < artistAlbums.length; i++) {
var option = document.createElement('option');
option.text = artistAlbums[i];
option.value = artistAlbums[i];
try { byId('albumSelect').add(option, null); } // non-IE
catch(e) { byId('albumSelect').add(option); } // IE
}
}
</script>
最佳答案
您的字符串之一包含双引号:
Array("Mazaak", "Fat Man Suicide", "25", "M", "200", "Includes classics like "Cream Green and Beans" and the title track "Fat Man Suicide"!")
你可以用黑斜杠来逃避它们
Array("Mazaak", "Fat Man Suicide", "25", "M", "200", "Includes classics like \"Cream Green and Beans\" and the title track \"Fat Man Suicide\"!")
或在字符串周围使用单引号
Array("Mazaak", "Fat Man Suicide", "25", "M", "200", 'Includes classics like "Cream Green and Beans" and the title track "Fat Man Suicide"!')
关于JavaScript 数组短路脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5135414/
我有一个 html 格式的表单: 我需要得到 JavaScript在value input 字段执行,但只能通过表单的 submit .原因是页面是一个模板所以我不控制它(不能有
我管理的论坛是托管软件,因此我无法访问源代码,我只能向页面添加 JavaScript 来实现我需要完成的任务。 我正在尝试用超链接替换所有页面上某些文本关键字的第一个实例。我还根据国家/地区代码对这些
我正在使用 JS 打开新页面并将 HTML 代码写入其中,但是当我尝试使用 document.write() 在新页面中编写 JS 时功能不起作用。显然,一旦看到 ,主 JS 就会关闭。用于即将打开的
提问不是为了解决问题,提问是为了更好地理解系统 专家!我知道每当你将 javascript 代码输入 javascript 引擎时,它会立即由 javascript 引擎执行。由于没有看过Engi
我在一个文件夹中有两个 javascript 文件。我想将一个变量的 javascript 文件传递到另一个。我应该使用什么程序? 最佳答案 window.postMessage用于跨文档消息。使
我有一个练习,我需要输入两个输入并检查它们是否都等于一个。 如果是 console.log 正则 console.log false 我试过这样的事情: function isPositive(fir
我正在做一个Web应用程序,计划允许其他网站(客户端)在其页面上嵌入以下javascript: 我的网络应用程序位于 http://example.org 。 我不能假设客户端网站的页面有 JQue
目前我正在使用三个外部 JS 文件。 我喜欢将所有三个 JS 文件合而为一。 尽一切可能。我创建 aio.js 并在 aio.js 中 src="https://code.jquery.com/
我有例如像这样的数组: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = {
所以我正在制作一个 Chrome 扩展,它使用我制作的一些 TamperMonkey 脚本。我想要一个“主”javascript 文件,您可以在其中包含并执行其他脚本。我很擅长使用以下行将其他 jav
我有 A、B html 和 A、B javascript 文件。 并且,如何将 A JavaScript 中使用的全局变量直接移动到 B JavaScript 中? 示例 JavaScript) va
我需要将以下整个代码放入名为 activate.js 的 JavaScript 中。你能告诉我怎么做吗? var int = new int({ seconds: 30, mark
我已经为我的 .net Web 应用程序创建了母版页 EXAMPLE1.Master。他们的 I 将值存储在 JavaScript 变量中。我想在另一个 JS 文件中检索该变量。 示例1.大师:-
是否有任何库可以用来转换这样的代码: function () { var a = 1; } 像这样的代码: function () { var a = 1; } 在我的浏览器中。因为我在 Gi
我收到语法缺失 ) 错误 $(document).ready(function changeText() { var p = document.getElementById('bidp
我正在制作进度条。它有一个标签。我想调整某个脚本完成的标签。在找到可能的解决方案的一些答案后,我想出了以下脚本。第一个启动并按预期工作。然而,第二个却没有。它出什么问题了?代码如下: HTML:
这里有一个很简单的问题,我简单的头脑无法回答:为什么我在外部库中加载时,下面的匿名和onload函数没有运行?我错过了一些非常非常基本的东西。 Library.js 只有一行:console.log(
我知道 javascript 是一种客户端语言,但如果实际代码中嵌入的 javascript 代码以某种方式与在控制台上运行的代码不同,我会尝试找到答案。让我用一个例子来解释它: 我想创建一个像 Mi
我如何将这个内联 javascript 更改为 Unobtrusive JavaScript? 谢谢! 感谢您的回答,但它不起作用。我的代码是: PHP js文件 document.getElem
我正在寻找将简单的 JavaScript 对象“转储”到动态生成的 JavaScript 源代码中的最优雅的方法。 目的:假设我们有 node.js 服务器生成 HTML。我们在服务器端有一个对象x。
我是一名优秀的程序员,十分优秀!