Skip to Main Content
JavaScript Application Cookbook
book

JavaScript Application Cookbook

by Jerry Bradenbaugh
October 1999
Intermediate to advanced content levelIntermediate to advanced
480 pages
14h 47m
English
O'Reilly Media, Inc.
Content preview from JavaScript Application Cookbook

frames.js

Practical use

Forced frame loading

Version requirement

JavaScript 1.1

Functions

keepIn(), keepOut()

This source file contains only two functions. One keeps your documents in a particular frameset. The other keeps your documents out of them. frames.js requires multiple HTML pages for its examples. For example, try to load ch06\frameset.html in your browser. This file is a frameset with two frames. One of the frames has file frames.html as the source. frames.html utilizes frames.js to ensure that frames.html is always loaded in the top window. That’s why loading frameset.html gives you the results shown in Figure 6.10 and Figure 6.11 (the browser loaded frames.html ).

Conversely, those who want to make certain that their files aren’t loaded unless they are in a particular frameset can use frames.js as well. Check out Figure 6.10, which shows what happens when you try to load ch06\frames2.html. You’ll get an alert stating the frameset violation, then the browser loads the corresponding frameset containing frames2.html. You can see this in Figure 6.11.

Busted by the frameset police

Figure 6-10. Busted by the frameset police

That’s better

Figure 6-11. That’s better

The code to accommodate this functionality is short and sweet. Function keepOut() compares document URL in the top window with the document URL of the current ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript Application Design

JavaScript Application Design

Nicolas Bevacqua
JavaScript Cookbook

JavaScript Cookbook

Shelley Powers

Publisher Resources

ISBN: 1565925777Supplemental ContentOtherErrata Page