How do I get the Window object from the Document object?

前端 未结 6 1678
太阳男子
太阳男子 2021-01-01 08:29

I can get window.document but how can I get document.window? I need to know how to do this in all browsers.

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 08:51

    Well, this is the solution I went with. It works, but I hate it.

    getScope : function(element) {
        var iframes = top.$$('iframe');
        var iframe = iframes.find(function(element, i) {
            return top[i.id] ? top[i.id].document == element.ownerDocument : false;
        }.bind(this, element));
        return iframe ? top[iframe.id] : top;
    }   
    

提交回复
热议问题