Wednesday, June 23, 2010

isDialog(window) and window.dialogArguments

How to do detection if window was opened with
shoModalDialog or showModelessDialog vs. with the window.open or other method.

Code was ugly because of non null opener returned in non MSIE browsers
and tricky window.dialogArguments if undefined and null values where passed to showModalDialogMethod

This is my proposal for reliable version test isDialog(window) tested in FF,MSIE 7,Chrome and Safari (originally it was 6 lines long with browser sniffing)

return "dialogArguments" in window;

Thanx http://perfectionkills.com/for inspiration.

No comments:

Post a Comment