Javascript中未定义的.function的最小条件检查
对不起,如果这个问题是以其他方式提出的。基本上我必须写下:Javascript中未定义的.function的最小条件检查,javascript,object,null,undefined,typeof,Javascript,Object,Null,Undefined,Typeof,对不起,如果这个问题是以其他方式提出的。基本上我必须写下: (window.name ="xyz" && ahdframeset == ahdtop && typeof window.parent.ahdframe.frames == "object" && typeof window.parent.ahdframe.frames [window.name] == "undefined" )) 我必须主要检查是否定义了win
(window.name ="xyz" && ahdframeset == ahdtop && typeof
window.parent.ahdframe.frames == "object" && typeof window.parent.ahdframe.frames
[window.name] == "undefined" ))
我必须主要检查是否定义了window.parent.ahdframe.frames[window.name].somefunction
?我可以使用类似于
(window.name ="xyz" && ahdframeset == ahdtop && typeof
window.parent.ahdframe.frames[window.name].somefunction == "undefined" ))
当window.parent.ahdframe为null或未定义时,不要担心javascript错误您不能仅仅“不担心javascript错误”。您必须测试属性以查看它们是否为空
(window.name ="xyz" && ahdframeset == ahdtop &&
window.parent && window.parent.ahdframe && window.parent.ahdframe.frames && window.parent.ahdframe.frames[window.name] &&
typeof window.parent.ahdframe.frames[window.name].somefunction == "undefined" ))