Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Web
Expertise: Intermediate
Sep 28, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Using JavaScript to Check if Frameset is Loaded

You can use JavaScript at the top of an HTML document to detect if a frameset is loaded and if not, load the frameset. If a window's top property points to the window itself then that frame is the main frameset or document:
<SCRIPT Language="JavaScript">
if (window.top == window) {
  window.top.location = "frame.htm";
<H1>This is document #1</H1>
If that's true in this case then the user has somehow bypassed the frameset that sets up your site's navigational elements. Simply changing the window's location property to the URL of the appropriate frameset HTML sets everything right. Also, this is a good way to check if your page is being displayed as part of someone else's frameset and break out of it if necessary:
<SCRIPT Language="JavaScript">
if (window.top != window) {
  window.top.location = window.location;
<FRAMESET COLS="30%,70%">
  <FRAME NAME="doc1" SRC="doc1.htm">
  <FRAME NAME="doc2" SRC="doc2.htm">
Boris Feldman
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date