Xem mẫu

Embedding Sound and Video There are two tags that are used to embed multimedia files in web pages and . The tag was introduced by Netscape to enable files that require plug-ins to view within a web page. The tag indicates that Netscape-style plug-ins (multimedia primarily) should be used to view embedded media. Unfortunately, isn`t sanctioned by the World Wide Web Consortium (W3C) and can`t be found in the official HTML standard. The other tag, , is officially sanctioned by the W3C. It was originally used by Internet Explorer to allow users to load ActiveX controls within a page. I`ll talk about them more a bit later. Since then, browsers that use Netscape-style plug-ins have also added support for the tag. The tag is only necessary for older browsers that use Netscape-style plug-ins (like old versions of Netscape). Using the Element Despite the fact that isn`t in the HTML standard, Microsoft and Netscape continue to support it, mainly because many pages out there that still use it. The tag has no closing tag; however, it does support a number of attributes. Unfortunately, despite the fact that most browsers support , they only have a handful of attributes in common. The good news is that each web browser ignores the attributes it doesn`t understand, enabling you to include as many different attributes as you like. Because of this, it`s best to rely on a set of attributes that will work in all cases, and use them religiously, including the others for added value. And, because the tag won`t validate anyway, you don`t have to worry about complying with standards with regard to the attributes either. Let`s explore the attributes you absolutely need to use the element. The src attribute contains the location of the multimedia file you want to embed in the web page. The height and width attributes specify the dimensions of the embedded file in pixels. There are some tricks to setting the height and width properties properly. If you`re presenting video, setting the height and width to the actual resolution of the movie causes the video to become crunched because the controls are displayed in that space as well. Figures 11.8 and 11.9 demonstrate the problem using the tags that follow: Input file:///G|/1/0672328860/ch11lev1sec3.html (1 von 16) [19.12.2006 13:49:25] Output Figure 11.8. An embedded movie that does not include space for the plug-in`s controls. Input Output Figure 11.9. An embedded movie with the proper proportions. file:///G|/1/0672328860/ch11lev1sec3.html (2 von 16) [19.12.2006 13:49:25] If you leave out the height and width attributes, the browser will determine how much space to reserve for the file. Unfortunately, this causes problems because each browser behaves differently. Internet Explorer 6 will provide too small a space, and only part of the movie will be shown. Mozilla Firefox provides too much space, leaving lots of padding around the movie. In other words, you need to specify a height and width. Table 11.1 summarizes the attributes supported by Internet Explorer. Table 11.1. Attributes Used in Internet Explorer Attribute align class height id name pluginspage Description Aligns the element in relation to the web page. Allowable values are absbottom, absmiddle, baseline, bottom, left, middle, right, texttop, and top. This is the equivalent of the tag`s align attribute. Sets or retrieves the class of the element. Used with CSS. The height of the element. The ID of the element. Used with JavaScript or CSS. The name of the element. Used with JavaScript. The URL of the page where you can download the plug-in used to view this object. file:///G|/1/0672328860/ch11lev1sec3.html (3 von 16) [19.12.2006 13:49:25] src style title units unselectable width The URL of the multimedia file. Style sheet declaration. The title of the element. Sets or retrieves the height or width units. Pixels are the default unit of measurement. Specifies that the object cannot be selected. Valid values are on and off (the default is off). The width of the element. Table 11.2 summarizes the attributes supported by Mozilla Firefox. Table 11.2. Attributes Used in Mozilla Firefox Attribute src type pluginspage pluginurl align border frameborder height width units hidden hspace vspace name palette Description The URL file location. The MIME type of the multimedia file indicated by the src attribute. A URL pointing to a web page that has instructions for installing the required plug-in. A URL to a Java Archive (JAR) file. Aligns the element in relation to the web page. Allowable values are left, right, top, and bottom. The width of a border drawn around the element. Does not draw a border around the element when set to no. The height of the element. The width of the element. The units used to measure the height and width. Pixels are the default unit of measurement. Hides the element when set to true and displays it when set to false, which is the default value. The horizontal margin around the element. The vertical margin around the element. The name of the plug-in required to play the file. For use in Windows only. foreground makes the plug-in use the foreground palette, whereas background (the default) makes the plug-in use the background palette. In addition to these attributes, additional attributes might be available for specific plug-ins, such as the file:///G|/1/0672328860/ch11lev1sec3.html (4 von 16) [19.12.2006 13:49:25] Macromedia Flash Player. Finally, you can include the noembed element to provide support for visitors who do not have a web browser that can display plug-ins: This Web page requires a browser that can display objects. ... - tailieumienphi.vn nguon tai.lieu . vn