When I read your question, first thing that crossed my mind was to read and act upon window.frames.length
. Exactly what you have done yourself.
However, you could pretty much see a frameset
and frame
as deprecated technologies nowadays. Instead, put the links in a HTML5 <nav> or regular <div>, then put the content in a HTML5 <article> or another regular <div>. Next load the content dynamically using vanilla/plain JavaScript or a framework such as jQuery.
If you insist on putting the navigation links in a "frame" that never goes away, and you want to load HTML files into a sub part of the screen, then I'd still put the navigation links in a <nav> or <div> and use an <iframe> for the content.