문제

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