您可以在这里找到很多关于尾随逗号的信息: 数组和对象中的尾随逗号是规范的一部分吗?
这是关于“就在那里”的逗号。
[
{ title: "..", display: function() { return ".."; } },
{ title: "..", display: function() { return ".."; } },
{ title: "..", display: function() { return ".."; } }, // <--right there
]
我现在的问题是,第 3 方工具生成此列表时带有尾随逗号,我无法访问此工具的源代码。一世
<body>
my stuff
<!-- the folloging div with the javascript comes from the 3rd party -->
<div class="item"><script type="text/javascript">
$(document).ready(function() {
$.supersized({
// Functionality
slide_interval : 8000, // Length between transitions
transition : 1, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed : 400, // Speed of transition
fit_always : 0, //Prevents the image from being cropped by locking it at 100% width.
min_width : 600, //min-width of images
random : 0, //random img
vertical_center : 1, //vertical alignment
// Components
slide_links : 'false', // Individual links for each slide (Options: false, 'number', 'name', 'blank')
slides : [ // Slideshow Images
{image : 'image1.jpg', otherstuff: 'blah', moreotherstuff: 'lorem'},
{image : 'image2.jpg', otherstuff: 'blub', moreotherstuff: 'ipsum'},
]
});
});
</script></div>
现在我问我有没有办法让它在 IE7/IE8 中工作。
我现在看到的唯一方法(因为我无法编辑第 3 方并且无法在服务器上访问它)是: - 在没有该 div 的情况下提供特殊输出 - 通过 ajax 请求正常端 - 解析所有内容,得到这个div,删除最后一个逗号并执行javascript
这真的不是我想要的方式。还有另一种方法可以解决这个问题吗?