自娱自乐

本人收藏的一些文章,供学习使用
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Permission denied to access property 'dom' from a non-chrome context

Posted on 2009-11-02 14:21  lwjacky  阅读(1424)  评论(0编辑  收藏  举报

这几天在做Ext的时候,用firefug调试程序的时候老是提示错误,错误信息如下:

Permission denied to access property 'dom' from a non-chrome context

上网google了一下,中文的解析没找到,经过一番折腾,在一个老外的帖子里了解到一知半解。似乎只是firefug的的一个bug,3.5版本的火狐就会有这个问题,由于网络延迟的问题,dom就出现了问题。这个老外牛人也提供了解决办法,我拿过来,果真有效。解决方法如下:

Ext.override(Ext.Element, {
    contains: function() {
        var isXUL = Ext.isGecko ? function(node) {
            return Object.prototype.toString.call(node) == '[object XULElement]';
        } : Ext.emptyFn;

        return function(el) {
            return !this.dom.firstChild || // if this Element has no children, return false immediately
                   !el ||
                   isXUL(el) ? false : Ext.lib.Dom.isAncestor(this.dom, el.dom ? el.dom : el);
        };
    }()
});

复写Ext的Element方法就行了。