对话框 普通页面
1.opener undefined A
2.dialogArguments B undefined
3.dialogWidth C:string undefined
A、B、C表示有多种情况
A:对于新开启的页面为undefined,其余情况都为object
B:当不传递参数时,为unknown
当传递参数不为undefined时,为参数类型
当传递参数为undefined时,为undefined
C:目前测试的所有结果都为string
注:对于普通页面的dialogArguments与dialogWidth必须保证没人将其定义为window的属性
所以最稳妥的测试方式应该是
function isDialog(w){ var openerType = typeof(w.opener); var dialogWidthType = typeof(w.dialogWidth); if (openerType == 'undefined' && dialogWidthType == 'string') { return true; } else { return false; } }