Sorry if this question has been asked in some different way. Basically I have to write this:

 (window.name ="xyz" && ahdframeset == ahdtop && typeof     
  window.parent.ahdframe.frames == "object" && typeof window.parent.ahdframe.frames  
 [window.name] == "undefined" ))

I have to mainly check if window.parent.ahdframe.frames[window.name].somefunction is defined or not ? Instead of verifying for object and undefined, can I use something like

 (window.name ="xyz" && ahdframeset == ahdtop && typeof     
  window.parent.ahdframe.frames[window.name].somefunction == "undefined" )) 

and not worry about javascript errors when window.parent.ahdframe is null or undefined

有帮助吗?

解决方案

You can't just "not worry about JavaScript errors". You have to test the properties to see whether they're empty.

(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" )) 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top