or "Evil twins" === vs. == in cross-windows communicationComparing window references or "Evil twins" === vs. == in cross-windows communication.
As you may have read in meany sources
=== is preffered over ==
Mr.D calls the == variant The evil twin, but... MSIE (again) may surprise you:
Lets have two windows A and B
now in A lets call this wierd construction:
// in window A, "ask window B to create object"
// code inside window B looks like this
//what DOES window mean:,
// a) is it wnd from "new wnd.Object1()" or
// b) is it callers window context ?
// see test case for answer ;-)
This construct will work
in all browsers
in all types of windows (iFrame, window.open, modal, modeless dialogs)
but and WILL NOT WORK in MSIE modelessDialog and window.open.
and the call will end up with "Invalid procedure call or argument".
However in those working in explorer (iframe and tweaked modal dialog)
let's try to compare window references:
// remote window is opener or parent or self
// depending on the type of "popup" method used
var remote=new remoteWnd.Object1();
asrt(remoteCtx===remoteWnd,"window refs broken ?");
All browsers (Safari, FF, Opera, Chrome) pass this test for
all supported types of cross-referenced windows (iFrame, window.open,showModalDialog)
MSIE (6,7,8) fails to compare window references with ===summary:
// does not work
// seems to work but what is actually compared ? (TODO: see specs.)
// works but means something different right ?
Of course there is more XB magic in cross-window communication
(MSIE and Safari identified as trouble makers)
and I may return with more notes....