javascript – 仅限Ext Js IE错误

前端之家收集整理的这篇文章主要介绍了javascript – 仅限Ext Js IE错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的网络应用程序在Firefox或Chrome上正常工作,但在IE中则不行.它向我显示以下消息:

Object doesn’t support this property or method

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

任何想法如何解决它?

顺便说一句:我正在使用ext 3.4.

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

  1. Ext.onReady(function() {
  2. var viewport = new Ext.Viewport({
  3. layout: 'border',renderTo: document.body,items: [{
  4. region: 'north',height: 25,xtype: 'toolbar',items: [{
  5. xtype: 'button',text: 'Início',iconCls: 'home',handler:function() {
  6. var tabs = Ext.getCmp('dynamic-tabs');
  7. tabs.add({
  8. title: 'Início',closable:true,iconCls:'home'
  9. }).show();
  10. }
  11. },{
  12. xtype: 'button',text: 'Sistema',iconCls: 'sistema',menu: {
  13. items: [{
  14. text: 'Usuários',iconCls: 'usuario',handler: function(){ },menu: {
  15. items: [{
  16. text: 'Teste1',handler: function(){
  17. var tabs = Ext.getCmp('dynamic-tabs');
  18. tabs.add({
  19. title: 'Teste1',autoLoad: 'iframe.PHP?url=index.PHP',iconCls: 'usuario'
  20. }).show();
  21. }
  22. },{
  23. text: 'Teste2',handler: function(){
  24. var tabs = Ext.getCmp('dynamic-tabs');
  25. tabs.add({
  26. title: 'Teste2',iconCls: 'usuario'
  27. }).show();
  28. }
  29. }]
  30. }
  31. },{
  32. text: 'Configurações',handler: function(){
  33. var tabs = Ext.getCmp('dynamic-tabs');
  34. tabs.add({
  35. title: 'Configurações',autoLoad: 'iframe.PHP?url=form.PHP',iconCls: 'sistema'
  36. }).show();
  37. }
  38. },{
  39. text: 'Relatório Vertical',iconCls: 'relatorio',handler: function(){
  40. var tabs = Ext.getCmp('dynamic-tabs');
  41. tabs.add({
  42. title: 'Relatório Vertical',autoLoad: 'iframe.PHP?url=relatorio_v.PHP',iconCls: 'relatorio'
  43. }).show();
  44. }
  45. },{
  46. text: 'Relatório Horizontal',handler: function(){
  47. var tabs = Ext.getCmp('dynamic-tabs');
  48. tabs.add({
  49. title: 'Relatório Horizontal',autoLoad: 'iframe.PHP?url=relatorio_h.PHP',iconCls: 'relatorio'
  50. }).show();
  51. }
  52. },'-',{
  53. text: 'Sair',iconCls: 'logoff',handler: function(){
  54. location.reload()
  55. }
  56. }]
  57. }
  58. },{
  59. xtype: 'button',text: 'Abas',iconCls: 'abas',menu: {
  60. items: [{
  61. text: 'Criar nova Aba',iconCls: 'tab_add',handler: function(){
  62. var tabs = Ext.getCmp('dynamic-tabs');
  63. tabs.add({
  64. title: 'Nova Aba',html: 'Tab Body',iconCls: 'tab_add'
  65. }).show()
  66. }
  67. },{
  68. text: 'Ir para a primeira Aba',iconCls: 'tab_go',handler: function(){
  69. tabs.setActiveTab(0);
  70. }
  71. },{
  72. text: 'Excluir 2a Aba',iconCls: 'tab_delete',handler: function(){
  73. var tabs = Ext.getCmp('dynamic-tabs');
  74. if (tabs.get(1)) {
  75. var tab = tabs.get(1);
  76. tabs.remove(tab);
  77. }
  78. }
  79. }]
  80. }
  81. },text: 'Menus',menu: {
  82. items: [{
  83. text: 'Sub-menus com título dif.',menu: {
  84. items: ['Título do Sub-menu',{
  85. text: 'Sub-menu #1',handler: function(){
  86. var tabs = Ext.getCmp('dynamic-tabs');
  87. tabs.add({
  88. title: 'Sub-menu #1',autoLoad: 'iframe.PHP?url=PHPinfo.PHP',iconCls: 'usuario'
  89. }).show();
  90. }
  91. },{
  92. text: 'Sub-menu #2',handler: function(){
  93. var tabs = Ext.getCmp('dynamic-tabs');
  94. tabs.add({
  95. title: 'Sub-menu #2',iconCls: 'usuario'
  96. }).show();
  97. }
  98. }]
  99. }
  100. },{
  101. text: 'Sub-menus com título igual',menu: {
  102. items: ['Sub-menus com título igual',{
  103. text: 'Sub-menu #1',handler: function(){
  104. var tabs = Ext.getCmp('dynamic-tabs');
  105. tabs.add({
  106. title: 'Sub-menu #1',iconCls: 'usuario'
  107. }).show();
  108. }
  109. },handler: function(){
  110. var tabs = Ext.getCmp('dynamic-tabs');
  111. tabs.add({
  112. title: 'Sub-menu #2',iconCls: 'usuario'
  113. }).show();
  114. }
  115. }]
  116. }
  117. },{
  118. text: 'Sub-menus sem título',menu: {
  119. items: [{
  120. text: 'Sub-menu #1',iconCls: 'usuario'
  121. }).show();
  122. }
  123. }]
  124. }
  125. },{
  126. text: 'Sub-menu grande',menu: {
  127. items: [{
  128. text: 'Nível #1',menu: {
  129. items: [{
  130. text: 'Nível #2',menu: {
  131. items: [{
  132. text: 'Nível #3',menu: {
  133. items: [{
  134. text: 'Nível #4 e etc...',handler: function(){ }
  135. }]
  136. }
  137. }]
  138. }
  139. }]
  140. }
  141. }]
  142. }
  143. }]
  144. }
  145. }]
  146. },{
  147. region: 'center',xtype: 'tabpanel',id: 'dynamic-tabs',items: [{
  148. title: 'Início',iconCls:'home'
  149. }]
  150. },{
  151. region: 'south',id: 'barra',items: [{
  152. xtype: 'tbtext',text: 'Pacific Tecnologia da Informação © 2011',html: '<img src=\'imagens/logo_peq.png\' />'
  153. }]
  154. }]
  155. });
  156.  
  157. var tabs = Ext.getCmp('dynamic-tabs'); tabs.setActiveTab(0); });

这是一个简单的示例菜单.我在IE 8中进行了测试,并在兼容模式下模拟了7.

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

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

IE的开发者工具显示

  1. <html class=" x-quirks ext-border-Box x-viewport">
  2. <head>
  3. <title></title>
  4. <body class=" ext-ie ext-ie7 x-border-layout-ct" id="ext-gen5" scroll="no">
  5. Texto -
  6. DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  7. Texto - Nó de Texto Vazio
  8. <Meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  9. <script language="javascript" src="js/ext/adapter/ext/ext-base.js" type="text/javascript"></script>
  10. etc...

我的HTML文件

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.  
  6. <script type="text/javascript" language="javascript" src="js/ext/adapter/ext/ext-base.js"></script>
  7. <script type="text/javascript" language="javascript" src="js/ext/ext-all-debug.js"></script>
  8. <script type="text/javascript" language="javascript" src="js/menu.js.PHP"></script>
  9. <script type="text/javascript" language="javascript" src="js/layout.js.PHP"></script>
  10. <link rel="stylesheet" type="text/css" href="js/ext/resources/css/ext-all.css" />
  11. <link rel="stylesheet" type="text/css" href="js/ext/resources/css/xtheme-blue.css" />
  12. <link rel="stylesheet" type="text/css" href="css/menu.css" />
  13. <link rel="stylesheet" type="text/css" href="css/layout.css" />
  14. <link rel="stylesheet" type="text/css" href="css/icones.css.PHP" /></head>
  15.  
  16. <body>
  17. </body>
  18. </html>

解决方法

我之前有过这个错误.在我的情况下,我有一个名为location的实体,ext从中创建了一个对象.现在,IE使用了JS本地位置对象,并尝试在其上执行方法.该错误看起来与您的错误大致相同.

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

编辑基于新的演示代码

您的HTML文件应该以

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

我从未对这些设置有任何问题.调试器可能看起来不同,因为ExtJS将在运行时添加类,但这应该是您的源HTML文件.

猜你在找的JavaScript相关文章