Setting a Target

If your site uses frames, it’s common to have a framed navigation bar that loads the different pages into the main frame. The main frame is the target for the links in the navigation bar, and to load that main frame using HTML, you use the target attribute of the <a> tag. But if you want to use both frames and XHTML Strict, JavaScript is the only way to set the target. That’s because the target attribute isn’t allowed in XHTML Strict, and you have to set the target in order to use frames.

The XHTML Strict frameset in Script 5.7 allows you to load your choice of page into the main content frame, just by clicking a link in the left frame (Script 5.8, detailed below). The result is shown in Figure 5.8.

Figure 5.8. Here’s a frame ...

Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.