Frage

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

War es hilfreich?

Lösung

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" )) 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top