Embedding Plugins - Java Script

To embed a plugin into a Web page, HTML offers the <object/> element. At the very least, <object/> requires four attributes:

  • type— The MIME type of the file or object being embedded
  • data— The URL of a file to load into the object
  • width— The horizontal space the object should take up in the page
  • height— The vertical space the object should take up in the page

The browser internally equates the MIME type of a file with a particular plugin,so setting the type attribute is enough to tell the browser which plugin to load.For example, the content type for a Flash file is application/x-shockwave-flash, so the following code is all you need to embed a Flash movie:

If there is no registered plugin for the MIME type,the browser may (depending on which one you are using) offer to install the correct plugin for the file.Many browsers also look for the pluginspage attribute, which is an unofficial attribute of <object/> (it doesn’t exist in the HTML specification). This attribute specifies where to find the plugin for the embedded object if it isn’t already on the user’s machine. Example:

Including parameters

Sometimes an object requires additional parameters before it can start running. To specify parameters for an embedded object,use the <param/> element with its name and value attributes:

Each object can have any number of parameters. Including parameters that aren’t necessary doesn’t have any negative effect.

Netscape 4.x

The old Netscape 4.x browsers don’t support the <object/> element, so you use the old Netscape proprietary <embed/> element. The <embed/> element accepts most of the same attributes as <object/> (indeed, <object/> was modeled after <embed/>), except the src attribute is used instead of data:

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java Script Topics