Wonderful Inline Frames
Originally introduced by Internet Explorer 3.0, iframes, inline or floating frames, were officially adopted in HTML 4.0. This is good news because they're very effective when put to appropriate use. The bad news is that they aren't supported by Netscape 4.61 and many other browsers. Netscape 6.0+ does have inline frame support.
Iframes work a bit differently from standard frames. First, you don't create a separate frameset for the frame. You place the iframe information directly inline in any regular page.
Iframes are extremely handy in terms of being able to update specific windows within a browser. They are often used to manage web advertisements, which are often delivered from another server and updated regularly. This means that the main HTML page never gets touchedjust the remote page does.
You aren't limited to just HTML pages. You can link to any kind of source in an iframe, including images and multimedia objects.
Inline frames can be placed anywhere on a page. Unlike standard frames, they do not require a frameset. As with standard frames, iframes do require an additional pagein this case text.html, to work (see Example 6-14).
Example 6-14. Inline frames
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Inline Frames</title> </head> <body> <iframe width="350" height="200" src="text.html" scrolling="auto" frameborder="1"> </iframe> </body> </html>
The browser will draw the iframe to your specifications. Here, I've got it set to a width of 350 pixels and a height of 200 pixels, with automatic scrolling and a frame border of 1 to help you visualize the results.
I like to think of iframes a lot like images or objects. They really do work in a very similar way: The browser draws the area and then inserts the objectin this case, another HTML fileinto the drawn area.
Figure 6-10 shows the results.
Figure 6-10. iframe in Mozilla.
Frames have backward-compatibility issues. All modern browsers implement them, but older browser might not have support. Usually in those instances, the iframe is completely ignored. There is no method such as noframes for iframes, either. So, although their use is often very convenient, you'll want to limit it to instances in which you do not have to support older web browsers.