window.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. if (!dojo._hasResource["dijit._base.window"]) { // _hasResource checks added by
  2. // build. Do not use
  3. // _hasResource directly in your
  4. // code.
  5. dojo._hasResource["dijit._base.window"] = true;
  6. dojo.provide("dijit._base.window");
  7. dijit.getDocumentWindow = function(doc) {
  8. // summary
  9. // Get window object associated with document doc
  10. // With Safari, there is not way to retrieve the window from the
  11. // document, so we must fix it.
  12. if (dojo.isSafari && !doc._parentWindow) {
  13. /*
  14. * This is a Safari specific function that fix the reference to the
  15. * parent window from the document object.
  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. // In some IE versions (at least 6.0), document.parentWindow does not
  26. // return a
  27. // reference to the real window object (maybe a copy), so we must fix it
  28. // as well
  29. // We use IE specific execScript to attach the real window reference to
  30. // document._parentWindow for later use
  31. if (dojo.isIE && window !== document.parentWindow && !doc._parentWindow) {
  32. /*
  33. * In IE 6, only the variable "window" can be used to connect events
  34. * (others may be only copies).
  35. */
  36. doc.parentWindow.execScript("document._parentWindow = window;",
  37. "Javascript");
  38. // to prevent memory leak, unset it after use
  39. // another possibility is to add an onUnload handler which seems
  40. // overkill to me (liucougar)
  41. var win = doc._parentWindow;
  42. doc._parentWindow = null;
  43. return win; // Window
  44. }
  45. return doc._parentWindow || doc.parentWindow || doc.defaultView; // Window
  46. }
  47. }