Fix for locating frames by name

If a site has certain frames, the iteration can error out early because j is null. By first checking that j isn't null or undefined, we avoid breaking this.