Cross frame navs

2013-11-21

I keep forgetting the various inconsistently named properties to move between document, window, and the owner frame of each. So here's how to do it in current browsers (IE10+, fwiw)...

Code:
// window -> frame
window.frameElement;

// document -> window
document.defaultView;

// frame -> window
frame.contentWindow;

// frame -> document
frame.contentDocument;

// window -> document (duh)
window.document;

// element -> document (the doc that created it, not necessarily the doc who has el in its DOM!)
el.ownerDocument;


Le sigh.