]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dijit/_base/window.js
Comment class stub
[eow] / static / dojo-release-1.1.1 / dijit / _base / window.js
1 if(!dojo._hasResource["dijit._base.window"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit._base.window"] = true;
3 dojo.provide("dijit._base.window");
4
5 dijit.getDocumentWindow = function(doc){
6         //      summary
7         //      Get window object associated with document doc
8
9         // With Safari, there is not way to retrieve the window from the document, so we must fix it.
10         if(dojo.isSafari && !doc._parentWindow){
11                 /*
12                         This is a Safari specific function that fix the reference to the parent
13                         window from the document object.
14                         TODO: #5711: should the use of document below reference dojo.doc instead
15                         in case they're not the same?
16                 */
17                 var fix=function(win){
18                         win.document._parentWindow=win;
19                         for(var i=0; i<win.frames.length; i++){
20                                 fix(win.frames[i]);
21                         }
22                 }
23                 fix(window.top);
24         }
25
26         //In some IE versions (at least 6.0), document.parentWindow does not return a
27         //reference to the real window object (maybe a copy), so we must fix it as well
28         //We use IE specific execScript to attach the real window reference to
29         //document._parentWindow for later use
30         //TODO: #5711: should the use of document below reference dojo.doc instead in case they're not the same?
31         if(dojo.isIE && window !== document.parentWindow && !doc._parentWindow){
32                 /*
33                 In IE 6, only the variable "window" can be used to connect events (others
34                 may be only copies).
35                 */
36                 doc.parentWindow.execScript("document._parentWindow = window;", "Javascript");
37                 //to prevent memory leak, unset it after use
38                 //another possibility is to add an onUnload handler which seems overkill to me (liucougar)
39                 var win = doc._parentWindow;
40                 doc._parentWindow = null;
41                 return win;     //      Window
42         }
43
44         return doc._parentWindow || doc.parentWindow || doc.defaultView;        //      Window
45 }
46
47 }