消息: 'null' 为空或不是对象
以下是download_tree.js的代码:
JavaScript code /* * Ext JS Library 2.1 * Copyright(c) 2006-2008, Ext JS, LLC. * licensing@extjs.com * * http://extjs.com/license */ Ext.onReady(function(){ // shorthand var Tree = Ext.tree; function fun(node){ if(node.leaf==true){ var frame = parent.document.getElementById("mainFrame"); frame.src=url_root+'/archive/DownloadDoc.a?selectInfo&cid='+node.id; } } var tree = new Tree.TreePanel({ el:'tree-div', useArrows:false, autoScroll:true, rootVisible:false, animate:true, //enableDD:true, containerScroll: false, baseCls:'', listeners:{click:fun}, loader: new Tree.TreeLoader({ dataUrl:url_root+'/ClassTreeAction.a?queryTreeNode' }) }); // set the root node var root = new Tree.AsyncTreeNode({ text: 'Ext js', draggable:false, id:'source' }); tree.setRootNode(root); // tree.setRootVisible(false); // render the tree tree.render(); // root.expand(); });
运行后提示:
网页错误详细信息
用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152)
时间戳: Wed, 26 Dec 2012 06:18:54 UTC
消息: 'null' 为空或不是对象
行: 16
字符: 9
代码: 0
URI: http://192.168.1.121/qasss/archive/download_tree.js
我现在用的是IE8,原来用IE6的时候似乎没这个问题。我现在不知道怎么改才能适应IE8,高手帮我看看,怎么修改合适?
感谢!
var frame = parent.document.getElementById("mainFrame");
frame.src=url_root+'/archive/DownloadDoc.a?selectInfo&cid='+node.id;
你页面不存在mainFrame这个ID的控件吧
var frame = parent.document.getElementById("mainFrame");
改成 var frame = getIFrameDOM("mainFrame");试试