Sams Teach Yourself JavaScript in 24 Hours

Sams Teach Yourself JavaScript in 24 Hours

By Michael Moncur

Introducing Plug-Ins

Plug-ins were introduced by Netscape in Navigator 3.0. Rather than adding support directly to the browser for media types such as formatted text, video, and audio, Netscape created a modular architecture that allows programmers to write their own browser add-ons for these features.

There are now hundreds of plug-ins available for both Netscape and Internet Explorer. Here are a few of the most popular:

Netscape and Internet Explorer use different plug-in formats and usually require different versions of a plug-in. Additionally, some plug-ins are available only for one platform, such as Windows or Macintosh.

Because Netscape's LiveAudio plug-in and Microsoft's Windows Media Player are included with Netscape 4.x and Internet Explorer, you can assume that much of your Web page's audience will have a plug-in for playing sounds. The workshop section of this hour will use these plug-ins to play sounds.

Using the <embed> Tag

You can include a file that uses a plug-in in a Web document with the <embed> tag. This tag specifies the filename for the content and any parameters required by the plug-in. Here is a simple example:

<embed SRC="sound.wav" HIDDEN=true AUTOSTART=false LOOP=false>

This example embeds the file sound.wav. The <embed> tag for sounds uses the following attributes:

Using the <object> Tag

The <embed> tag has been deprecated in the HTML 4.0 standard in favor of a new tag, <object>. This tag allows you to specify the same parameters and many others to embed a sound or other plug-in object. Here is an example <object> tag to include a sound within a Web page:

<object type="audio/x-wav" data="sound.wav" width="100" height="50">
  <param name="src" value="sound.wav">
  <param name="autostart" value="false">
  <param name="hidden" value="true">
</object>

This tag embeds a hidden sound object, similar to the <embed> tag example in the previous section.

Understanding MIME Types

Multipurpose Internet Mail Extensions (MIME) is a standard for classifying different types of files and transmitting them over the Internet. The different types of files are known as MIME types.

You've already worked with a few MIME types: HTML (MIME type text/html), text (MIME type text/plain), and GIF images (MIME type image/gif). Although Web browsers don't normally support many more than these types, external applications and plug-ins can provide support for additional types.

When a Web server sends a document to a browser, it includes that document's MIME type in the heading. If the browser supports that MIME type, it displays the file. If not, you're asked what to do with the file (such as when you click on a .zip or .exe file to download it).

Share ThisShare This

Informit Network