2011-03-18 122 views
0

我有一个JavaScript代码,包含数组尾随逗号ExtJS的问题与Internet Explorer 8

items:[{ 
    id: 'col-1', 
    flex: 1 , //this comma is the source of the problem 
    },{ 
    id: 'col-2', 
    flex: 1, 
    } 
    ] 

因此,这里是我的问题,当我有这个逗号,它的工作原理上的Internet Explorer 8本地主机,但当我尝试从服务器访问它时,它不起作用,当我删除它时,它工作正常。我在互联网上搜索,答案是,IE不支持尾随逗号,但在这种情况下,为什么它从本地主机而不是服务器上工作?

我使用的怪癖兼容模式,我不会在头部X-UA-兼容有,这里的头

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <meta name="Description" content="Default Style" /> 
    <meta name="Version" content="2.1.1" /> 
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 
    <title>project name</title> 
    <link rel="stylesheet" type="text/css" href="./style/default/main.css" media="all" /> 
    <style type="text/css" media="all">@import "./style/default/main.css";</style> 
    <link rel="shortcut icon" href="./style/default/images/favicon.ico" type="image/ico" /> 
    <script type="text/javascript" src="http://10.215.63.218/Apsys/js/base.js"></script> 
<script type="text/javascript" src="http://10.215.63.218/app/js/collapse.js"></script> 
<script type="text/javascript" src="http://10.215.63.218/app/lib/overlib/overlib.js"></script> 
</head> 

回答

1

我想像的是,后面的逗号错误是固定在IE8 ,但是当您在服务器上查看时,您在Quirks模式或IE7兼容模式下这样做。

+0

当我在服务器上查看它时,我没有使用Quirks模式或IE7兼容性 – Mansuro 2011-03-18 08:47:14

2

尾随逗号是不必要的,应该避免它也是一种不好的编码习惯。

2

您应该删除所有尾随逗号。 Firefox不会窒息他们,但IE的版本会。