Ext Js只有IE错误

Ext Js IE error only

本文关键字:错误 IE 只有 Js Ext      更新时间:2023-09-26

我的web应用程序在Firefox或Chrome上运行良好,但在IE中不行。它显示了以下消息:

对象不支持此属性或方法

File: ext-all.js - Line: 7 - Char: 6100

有什么好办法吗?

BTW:我使用ext 3.4.

编辑:我所有的ext布局创建器代码:

Ext.onReady(function() { 
var viewport = new Ext.Viewport({ 
    layout: 'border', 
    renderTo: document.body, 
    items: [{ 
        region: 'north', 
        height: 25, 
        xtype: 'toolbar', 
        items: [{ 
            xtype: 'button', 
            text: 'Início', 
            iconCls: 'home', 
            handler:function() { 
                var tabs = Ext.getCmp('dynamic-tabs'); 
                tabs.add({ 
                    title: 'Início', 
                    closable:true, 
                    iconCls:'home' 
                }).show(); 
            } 
        }, { 
            xtype: 'button', 
            text: 'Sistema', 
            iconCls: 'sistema',
             menu: {
                 items: [{
                     text: 'Usuários', 
                     iconCls: 'usuario', 
                     handler: function(){ }, 
                     menu: { 
                        items: [{ 
                            text: 'Teste1',
                            iconCls: 'usuario', 
                            handler: function(){ 
                                var tabs = Ext.getCmp('dynamic-tabs'); 
                                tabs.add({ 
                                    title: 'Teste1', 
                                    closable:true, 
                                    autoLoad: 'iframe.php?url=index.php', 
                                    iconCls: 'usuario' 
                                }).show(); 
                            }
                        }, { 
                            text: 'Teste2', 
                            iconCls: 'usuario', 
                            handler: function(){ 
                                var tabs = Ext.getCmp('dynamic-tabs'); 
                                tabs.add({ 
                                    title: 'Teste2', 
                                    closable:true, 
                                    autoLoad: 'iframe.php?url=index.php', 
                                    iconCls: 'usuario' 
                                }).show(); 
                            } 
                        }] 
                    }
                }, { 
                    text: 'Configurações', 
                    iconCls: 'sistema', 
                    handler: function(){ 
                        var tabs = Ext.getCmp('dynamic-tabs'); 
                        tabs.add({ 
                            title: 'Configurações', 
                            closable:true, 
                            autoLoad: 'iframe.php?url=form.php', 
                            iconCls: 'sistema' 
                        }).show(); 
                    }
                }, { 
                    text: 'Relatório Vertical', 
                    iconCls: 'relatorio', 
                    handler: function(){ 
                        var tabs = Ext.getCmp('dynamic-tabs'); 
                        tabs.add({
                            title: 'Relatório Vertical', 
                            closable:true, 
                            autoLoad: 'iframe.php?url=relatorio_v.php', 
                            iconCls: 'relatorio'
                        }).show(); 
                    } 
                }, { 
                    text: 'Relatório Horizontal',
                    iconCls: 'relatorio', 
                    handler: function(){ 
                    var tabs = Ext.getCmp('dynamic-tabs'); 
                    tabs.add({ 
                        title: 'Relatório Horizontal', 
                        closable:true, 
                        autoLoad: 'iframe.php?url=relatorio_h.php', 
                        iconCls: 'relatorio' 
                    }).show(); 
                } 
            },
            '-', { 
                text: 'Sair', 
                iconCls: 'logoff', 
                handler: function(){
                    location.reload() 
                } 
            }] 
        } 
    }, { 
        xtype: 'button', 
        text: 'Abas', 
        iconCls: 'abas', 
        menu: { 
            items: [{ 
                text: 'Criar nova Aba', 
                iconCls: 'tab_add', 
                handler: function(){ 
                    var tabs = Ext.getCmp('dynamic-tabs'); 
                    tabs.add({
                        title: 'Nova Aba', 
                        html: 'Tab Body', 
                        closable:true, 
                        iconCls: 'tab_add' 
                    }).show() 
                } 
            }, { 
                text: 'Ir para a primeira Aba', 
                iconCls: 'tab_go', 
                handler: function(){
                    tabs.setActiveTab(0); 
                }
            }, { 
                text: 'Excluir 2a Aba', 
                iconCls: 'tab_delete', 
                handler: function(){ 
                    var tabs = Ext.getCmp('dynamic-tabs'); 
                    if (tabs.get(1)) { 
                        var tab = tabs.get(1); 
                        tabs.remove(tab); 
                    } 
                } 
            }] 
        } 
    }, { 
        xtype: 'button', 
        text: 'Menus', 
        iconCls: 'usuario', 
        menu: { 
            items: [{ 
                text: 'Sub-menus com título dif.', 
                iconCls: 'usuario', 
                handler: function(){ }, 
                menu: {
                    items: ['Título do Sub-menu', 
                    { 
                        text: 'Sub-menu #1', 
                        iconCls: 'usuario', 
                        handler: function(){ 
                            var tabs = Ext.getCmp('dynamic-tabs');
                            tabs.add({ 
                                title: 'Sub-menu #1', 
                                closable:true, 
                                autoLoad: 'iframe.php?url=phpinfo.php', 
                                iconCls: 'usuario'
                            }).show(); 
                        } 
                    }, { 
                        text: 'Sub-menu #2', 
                        iconCls: 'usuario', 
                        handler: function(){ 
                            var tabs = Ext.getCmp('dynamic-tabs'); 
                            tabs.add({
                                title: 'Sub-menu #2', 
                                closable:true, 
                                autoLoad: 'iframe.php?url=phpinfo.php', 
                                iconCls: 'usuario'
                            }).show(); 
                        } 
                    }] 
                }
            }, { 
                text: 'Sub-menus com título igual',
                iconCls: 'usuario', 
                handler: function(){ }, 
                menu: {
                    items: ['Sub-menus com título igual', 
                    {
                        text: 'Sub-menu #1', 
                        iconCls: 'usuario', 
                        handler: function(){ 
                            var tabs = Ext.getCmp('dynamic-tabs'); 
                            tabs.add({
                                title: 'Sub-menu #1', 
                                closable:true, 
                                autoLoad: 'iframe.php?url=phpinfo.php', 
                                iconCls: 'usuario'
                            }).show(); 
                        }
                    }, { 
                        text: 'Sub-menu #2', 
                        iconCls: 'usuario', 
                        handler: function(){ 
                            var tabs = Ext.getCmp('dynamic-tabs'); 
                            tabs.add({ 
                                title: 'Sub-menu #2', 
                                closable:true, 
                                autoLoad: 'iframe.php?url=phpinfo.php', 
                                iconCls: 'usuario'
                            }).show();
                        } 
                    }] 
                } 
            }, { 
                text: 'Sub-menus sem título', 
                iconCls: 'usuario', 
                handler: function(){ }, 
                menu: { 
                    items: [{ 
                        text: 'Sub-menu #1', 
                        iconCls: 'usuario', 
                        handler: function(){ 
                            var tabs = Ext.getCmp('dynamic-tabs'); 
                            tabs.add({
                                title: 'Sub-menu #1', 
                                closable:true, 
                                autoLoad: 'iframe.php?url=phpinfo.php', 
                                iconCls: 'usuario'
                            }).show(); 
                        } 
                    }, { 
                        text: 'Sub-menu #2', 
                        iconCls: 'usuario', 
                        handler: function(){ 
                            var tabs = Ext.getCmp('dynamic-tabs'); 
                            tabs.add({ 
                                title: 'Sub-menu #2', 
                                closable:true, 
                                autoLoad: 'iframe.php?url=phpinfo.php', 
                                iconCls: 'usuario'
                            }).show(); 
                        } 
                    }] 
                } 
            }, { 
                text: 'Sub-menu grande', 
                iconCls: 'usuario', 
                handler: function(){ }, 
                menu: { 
                    items: [{
                        text: 'Nível #1', 
                        iconCls: 'usuario', 
                        handler: function(){ }, 
                        menu: { 
                            items: [{ 
                                text: 'Nível #2', 
                                iconCls: 'usuario', 
                                handler: function(){ }, 
                                menu: { 
                                    items: [{ 
                                        text: 'Nível #3', 
                                        iconCls: 'usuario', 
                                        handler: function(){ }, 
                                        menu: { 
                                            items: [{ 
                                                text: 'Nível #4 e etc...', 
                                                iconCls: 'usuario', 
                                                handler: function(){ } 
                                            }] 
                                        } 
                                    }] 
                                } 
                            }] 
                        } 
                    }] 
                } 
            }] 
        } 
    }] 
} , { 
    region: 'center', 
    xtype: 'tabpanel', 
    id: 'dynamic-tabs', 
    items: [{
        title: 'Início', 
        autoLoad: 'iframe.php?url=phpinfo.php', 
        iconCls:'home'
}] 
} , { 
    region: 'south', 
    xtype: 'toolbar', 
    id: 'barra', 
    height: 25, 
    items: [{ 
        xtype: 'tbtext', 
        text: 'Pacific Tecnologia da Informação © 2011', 
        html: '<img src=''imagens/logo_peq.png'' />' 
    }] 
}] 
}); 
var tabs = Ext.getCmp('dynamic-tabs'); tabs.setActiveTab(0); });

这是一个简单的菜单样本。我在ie8和模拟ie7的兼容模式下进行了测试。

有趣的观察:在Firefox firebug的控制台显示:

  <html xmlns="http://www.w3.org/1999/xhtml" class=" x-viewport">
    <head></head>
    <body id="ext-gen5" class=" ext-gecko ext-gecko3 x-border-layout-ct">
    etc...

IE的开发人员工具显示:

    <html class=" x-quirks  ext-border-box x-viewport">
    <head>
    <title></title>
    <body class="   ext-ie ext-ie7 x-border-layout-ct" id="ext-gen5" scroll="no">
    Texto - 
    DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    Texto - Nó de Texto Vazio
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script language="javascript" src="js/ext/adapter/ext/ext-base.js" type="text/javascript"></script>
    etc... 
我的HTML文件:
<!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">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <script type="text/javascript" language="javascript" src="js/ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" language="javascript" src="js/ext/ext-all-debug.js"></script>
    <script type="text/javascript" language="javascript" src="js/menu.js.php"></script>
    <script type="text/javascript" language="javascript" src="js/layout.js.php"></script>
    <link rel="stylesheet" type="text/css" href="js/ext/resources/css/ext-all.css" />
    <link rel="stylesheet" type="text/css" href="js/ext/resources/css/xtheme-blue.css" />
    <link rel="stylesheet" type="text/css" href="css/menu.css" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" />
    <link rel="stylesheet" type="text/css" href="css/icones.css.php" /></head>
 
<body>
</body>
</html>

我以前有这个错误。在我的例子中,我有一个名为location的实体,ext从它创建了一个对象。现在IE使用JS原生位置对象并尝试在其上执行方法。这个错误看起来和你的错误差不多。

使用IE开发人员工具栏并调试代码以确定确切的对象。这就是我解决这个问题的方法!

基于新的Demo代码编辑:

你的HTML文件应该以 开头
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

这些设置我从来没有遇到过任何问题。调试器可能看起来不同,因为ExtJS会在运行时添加类,但这应该是你的源HTML文件。

似乎你试图调用IE是唯一一个不能理解的属性或方法。您是否使用了一些除了IE之外所有人都知道的本机对象?

在不支持它的对象上调用方法或属性。试着找出那个对象是什么类型的,并给它添加方法。

你能提供一些代码吗?

可以包含ext-all-debug.js而不是ext-all.js吗?然后告诉我们是哪一行抛出了错误?一些可能的解决方案http://www.sencha.com/forum/showthread.php?81087 -开- 418 3.0.0 el.ownerdocument.createrange () -error-in-IE8

ext js - IE 8中el.ownerDocument.createRange()错误

以下是我在Ext/IE中解决此问题的方法:

  1. 检查悬空逗号。旧版本的IE不喜欢}或]前面有逗号。Ext的编码风格很可能导致这种错误。我用这个(jEdit)正则表达式搜索:",(' s * ' n * ' s * [} |]])"

  2. 使用警报来识别导致错误的代码行。您可能会将对象传递给Ext函数。此对象可能为空/未定义或不是预期的类型。在这里,警告(某种类型)可能会有所帮助。如果没有明显的入口点,请查看"xtype"定义和侦听器:其中一个可能是无效的

  3. 小心全局中毒。我最近遇到了一个问题,我有一个全局JS变量与DIV的id属性同名。IE试图使每个DOM id的全局变量,我拿起错误的一个。如果这影响到您,可能是因为局部函数变量缺少"var"关键字,因此与全局空间冲突。

您可能遇到过可怕的"owner.createDocument "。createRange IE Bug"

一些解决方案指向第一个节点无效的事实。

这里有两种可能的解决方案:

http://www.sencha.com/forum/showthread.php?7912-CLOSED-owner.createDocument.createRange-JS-error&突出= createRange

ext js - IE 8中的el.ownerDocument.createRange()错误

好运

这是一个IE Bug,可能会在版本4中修复