繁体   English   中英

extjs和Internet Explorer 8的问题

[英]problem with extjs and internet explorer 8


我用extjs库编写了一个程序,该程序在所有浏览器中工作正常,除了Internet Explorer 8,问题是,当我从localhost加载它时,它工作,但是当从服务器访问时,它不加载页面,我有一个空白页面,
我删除了一个逗号,程序从服务器访问时开始工作。 有人有解释吗?

这是标题:

 <!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>

Internet Explorer无法处理对象和数组上的尾随逗号。 这成为Ext的一个特别反复出现的问题,你经常创建大对象,每行一个属性,以及评论/删除很多东西。

这将在IE中打破:

new Ext.Panel({
    id: 'mypanel',
    cls: 'my-panel-class',
    html: 'Some HTML',
    colors: [
        'yellow',
        'blue',
        'red',
        //'pink'
    ],
    renderTo: Ext.getBody(),
});

注意第一个块中'red'Ext.getBody()之后的额外逗号。

这将有效:

new Ext.Panel({
    id: 'mypanel',
    cls: 'my-panel-class',
    html: 'Some HTML',
    colors: [
        'yellow',
        'blue',
        'red'
        //'pink'
    ],
    myArray: ['yellow', 'blue', 'red'],
    renderTo: Ext.getBody()
});

对于localhost与服务器之间的区别,IE中有一个设置会强制内部网站进入兼容模式,而不管doctype如何。 这可以解释功能之间的区别,如果你设置它。

无论哪种方式,您都应该保持良好的语法,并且不要在数组或对象中使用尾随逗号。

为什么Explorer在localhost中工作而不在已发布的服务器中工作是一个真正的谜,但是,检查你的HTML,我的示例在Chrome和Explorer 8(在localhost中)运行正确我的错误:

<body style="text-align:center">
<div id="bodyForm" style="width:100%;">
</div>
</body>

在app.js

renderTo: Ext.get('bodyForm')

我更正:

<body id="idBody">
</body>

在app.js中:

renderTo: Ext.get('idBody')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM