I have a piece of JavaScript that's part of a library that I want enabled only if a certain frameset is available.
What I wanted to do was just do:
if (typeof(top.TableOfContents.frames.content)!=='undefined') {
// stuff I want to do only if there's a frame named
// TableOfContents with a frame named content
}
Now, I get errors with that if the frames are not available, so what I'm doing now is:
if (typeof(top.TableOfContents)!=='undefined'
&& typeof(top.TableOfContents.frames)!=='undefined'
&& typeof(top.TableOfContents.frames.content)!=='undefined'){
// stuff I want to do only if there's a frame named
// TableOfContents with a frame named content
}
But it feels like there might be a better way to do this (beyond losing the frames, haha)... is there a more efficient or less verbose way to test for an object and the child objects and the grandchild objects?
Now, these are all frames referenced with relative urls, so there should be no "same origin policy" issues that I can think of (I've not run into anything in my testing).