Dealing with Older Browsers

There's a slight problem with the JavaScript skeleton in Figure 1-4 (besides the fact that it doesn't really have any JavaScript in it): Netscape didn't introduce the <script> tag until version 2.0 of Netscape Navigator, so any browser released before 1997 won't recognize the tag.

When a browser sees an HTML tag it doesn't understand, it just ignores that tag. That's generally a good thing. However, a browser that doesn't understand JavaScript will write your lines of JavaScript to the browser as text. Figure 1-5 shows how the JavaScript skeleton in Figure 1-4 would be displayed in an older browser.

What would display in an older browser

Figure 1-5. What Figure 1-4 ...

Get The Book of JavaScript, 2nd 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.