Lemur zaprasza
HTML Tag Reference [Contents] [Previous] [Next] [Alphabetical Tag List] [Index] HTML Tag Reference Applets and Plug-ins This section discusses the tags that let you include applets and plug-ins in your web document. APPLET PARAM EMBED NOEMBED OBJECT APPLET (Java applet) The APPLET tag specifies a Java applet that will run in a web page. Applets can only be displayed by Java-enabled browsers. Navigator 2.0 You build an applet using the Java language and compile it with a Java compiler. It is beyond the scope of this document to discuss how to write Java applets. However, an excellent place to start learning about writing Java is the Java Tutorial at: http://java.sun.com/docs/books/tutorial/ After writing and compiling a Java applet, you can display it in a web page by using the APPLET tag. The CODE attribute specifies the name of the Java applet to run. The CODEBASE attribute specifies the subdirectory or folder containing the Java applet. You can use PARAM tags between the <APPLET> and </APPLET> tags to provide information about parameters, or arguments, to be used by the Java applet. Syntax <APPLET CODE="classFileName" CODEBASE="classFileDirectory" ARCHIVE="archiveFile" ALT="altText" ALIGN="LEFT"|"RIGHT"|"TOP"|"ABSMIDDLE"|"ABSBOTTOM"| "TEXTTOP"|"MIDDLE"|"BASELINE"|"BOTTOM" HEIGHT="height" WIDTH="width" HSPACE="horizMargin" VSPACE="vertMargin" MAYSCRIPT NAME="value" > <PARAM ...> </APPLET> The CODE attribute is required (otherwise there is no applet to run). Netscape Navigator 3 and Navigator 4 can display applets if the WIDTH and HEIGHT attributes are omitted, but some other browsers cannot, so for best results you should always include the WIDTH and HEIGHT attributes. CODE ="classFileName" specifies the filename of the applet to load. All Java class files end with a .class extension (for example, myApplet.class). Many browsers will display the applet correctly even if you omit the .class extension in the filename. CODEBASE="classFileDirectory" is the directory containing the applet class file and any resources the applet needs. The value is a URL for an absolute or a relative pathname. An absolute URL is used as is without modification and is not affected by the document's BASE tag. A relative CODEBASE attribute is relative to the document's base URL defined by the BASE tag. If the document does not define a BASE tag, it is relative to the directory containing the HTML file. ARCHIVE="archiveFile" is a URL for a file in the CODEBASE directory to be downloaded to the user's disk. The suffix on the archive file must be .zip, but the file must not be compressed. The browser searches the archive file for the class file named in the CODE attribute. If the browser cannot find that class file in the archive file, it searches for it using the standard mechanism.Navigator 3.0 ALT="altText" specifies text to be displayed by browsers that do not support the APPLET tag. Navigator 3.0 ALIGN specifies the alignment for the applet. If you do not provide a value for ALIGN, Navigator uses BOTTOM as the default. LEFT aligns the applet with the left margin. Content following the applet flows around the applet on the right. You can use <BR CLEAR> to make content appear below the applet. RIGHT aligns the applet with the right margin. Content following the applet flows around the applet on the left. You can use <BR CLEAR> to make content appear below the applet. TOP: The top of the applet is vertically aligned with the tallest item in the current line. Only one line of content is aligned with the applet. Subsequent lines of content in the same block-level element appear below the applet. If the applet is not surrounded by content in the same block-level element as the applet, then it is aligned on the left. ABSMIDDLE: The middle of the applet is vertically aligned with the vertical middle of other content (such as text or images) in the current line. The content is moved down from its natural position in the page to accommodate the alignment. Only one line of content is aligned with the applet. Subsequent lines of content appear below the applet. If the applet is not surrounded by content in the same block-level element as the applet, then it is aligned on the left. Navigator 3.0 ABSBOTTOM : The bottom of the applet is vertically aligned with the bottom of other content (such as text or images) in the current line. The content is moved down from its natural position in the page to accommodate the alignment. Only one line of content is aligned with the applet. Subsequent lines of content appear below the applet. If the applet is not surrounded by content in the same block-level element as the applet, then it is aligned on the left. Navigator 3.0 TEXTTOP aligns the top of the applet with the top of the tallest text in the current line. If the current line contains no text, the top of the applet is aligned with the vertical middle of other content (such as images) in the line. If the applet is not surrounded by content in the same block-level element as the applet, then it is aligned on the left. Navigator 3.0 MIDDLE: The middle of the applet is vertically aligned with the bottom (or baseline) of other content (such as text or images) in the current line. The content is moved down from its natural position in the page to accomodate the alignment. Only one line of content is aligned with the applet. Subsequent lines of content appear below the applet. If the applet is not surrounded by content in the same block-level element as the applet then it is aligned on the left. Navigator 3.0. BASELINE -- The bottom of the applet is vertically aligned with the bottom (or baseline) of other content (such as text or images) in the current line. The content is moved down from its natural position in the page to accomodate the alignment. Only one line of content is aligned with the applet. Subsequent lines of content appear below the applet. If the applet is not surrounded by content in the same block-level element as the applet then it is aligned on the left. Navigator 3.0. BOTTOM is the same as BASELINE. HEIGHT="height" specifies the height of the applet. An integer value (for example, "100") indicates the height in pixels. A percentage value (for example, "25%") indicates the height as a percentage of the height of the parent window, frame, or block of content. The applet is scaled to fit the specified height and width.You should provide a width and height to ensure that all Java-enabled browsers can display the applet. WIDTH="width" specifies the width of the applet. An integer value (for example, "100") indicates the width in pixels. A percentage value, (for example, "25%") indicates the width as a percentage of the width of the parent window, frame, or block of content. The applet is scaled to fit the specified height and width. You should provide a width and height to ensure that all Java-enabled browsers can display the applet. HSPACE="horizMargin" specifies the horizontal space, in pixels, between the applet and surrounding text. Give the value as an integer. VSPACE="vertMargin" specifies the vertical space, in pixels, between the applet and surrounding text. Give the value as an integer. MAYSCRIPT permits the applet to access JavaScript. Use this attribute to determine whether or not an applet can access JavaScript on a page. If an applet accesses JavaScript when the MAYSCRIPT attribute is not specified, an exception will be generated. Navigator 3.0 NAME ="value" specifies the name of the applet, so that different applets in the same window can refer to (and communicate with) one another. The name can also be used by JavaScript functions and scripts. Applet Example The following example runs the applet jumping.class. It has two input parameters, message and speed, that affect the results of the applet. When this applet runs, it displays the words in the message, a few words at a time. The words come and go, so they seem to jump around at the specified speed. <P>Here is an applet. It has two parameters -- speed and message. <APPLET CODE="jumping.class" CODEBASE=jclasses WIDTH=240 HEIGHT=400 ALIGN=ABSMIDDLE HSPACE=10 VSPACE=20> <PARAM NAME=message VALUE="Use Netscape Navigator to browse the world wide web."> <PARAM NAME=speed VALUE="4"> </APPLET> Its alignment is ABSMIDDLE. </P> The file jumping.htm shows this example in action in a separate window. PARAM (parameter for an applet) The PARAM tag provides a value for a parameter required by an applet. The PARAM tag is used between <APPLET> and </APPLET>. Syntax <PARAM NAME="paramName" VALUE="value" > NAME="paramName" specifies the name of the variable. The name is determined by the applet. VALUE="value" specifies the value for the variable. Used Within APPLET Example See Applet Example. EMBED (embedded plug-in) The EMBED tag displays output from a file that is executed by a plug-in. The output is displayed as part of the HTML document in a rectangular area of the page. Navigator 2.0 A plug-in is an application written in a language such as C or C++ that has been plugged in to Navigator, so that it acts as an extension to the Navigator browser. When loaded, an embedded plug-in is displayed as part of the HTML document in a rectangular region of the page. This is similar to the way a GIF or JPEG image is embedded, except that the plug-in can be live and respond to user events, such as mouse clicks. It is beyond the scope of this document to discuss how to build plug-ins. For more information about plug-ins, see the Plug-In Guide. The EMBED tag has an SRC attribute that specifies the file to run. The TYPE attribute specifies the MIME type of the plug-in needed to run the file. Navigator uses either the value of the TYPE attribute or the suffix of the filename given as the SRC to determine which plug-in to use. You must provide either the SRC or TYPE attribute. Users must have the appropriate plug-in installed in their browsers before they can see the results of running an embedded file that uses a plug-in. If a user opens a web document that uses an EMBED tag, and the plug-in needed by the EMBED tag is already installed, the results of running the embedded file are displayed automatically. If a user tries to open a web page that loads an uninstalled plug-in, the browser asks if the user wants to to install the plug-in. If the user ignores the prompt to load the plug-in, the browser displays a puzzle piece in the space reserved for the embedded file. The user can click on this at any time to get the Plug-in Finder page. This page takes the MIME type and file extension for the plug-in and tries to match it to available MIME handlers on the web site. You can use the NOEMBED tag to provide text to be displayed by browsers that cannot display plug-ins. Syntax <EMBED SRC="location" TYPE="MIMEtype" PLUGINSPAGE="instrURL" PLUGINURL="pluginURL" ALIGN="LEFT"|"RIGHT"|"TOP"|"BOTTOM" BORDER="borderWidth" FRAMEBORDER="NO" HEIGHT="height" WIDTH="width" UNITS="units" HIDDEN="TRUE|FALSE HSPACE="horizMargin" VSPACE="vertMargin" NAME="pluginName" PALETTE="FOREGROUND"|"BACKGROUND" > ... </EMBED> The HEIGHT attribute is required. You must also supply either the SRC or TYPE attribute. In addition to these standard attributes, plug-ins can optionally have private attributes to communicate specialized information between the HTML page and the plug-in code. Netscape Navigator ignores all nonstandard attributes when parsing the HTML. It passes all attributes to the plug-in, allowing the plug-in to examine the list for any private attributes that could modify its behavior. SRC="location" optionally indicates the location of the plug-in data file by its URL. The MIME type of the file (typically based on the filename suffix) determines which plug-in is loaded to handle this EMBED tag. You must include either the SRC attribute or the TYPE attribute in an EMBED tag. TYPE="MIMEtype" specifies the MIME type of the EMBED tag, which in turn determines which plug-in to load. Use the TYPE attribute for a plug-in that requires no data, for example, a plug-in that draws an analog clock or fetches all of its data dynamically. For a visible plug-in, you must include both the WIDTH and HEIGHT attributes if you use TYPE; no default values are used. PLUGINSPAGE="instrURL" specifies the URL that contains the instructions for installing the plug-in if it is not already installed. PLUGINURL="pluginURL" is the URL of a Java Archive (JAR) file, which is a compressed collection of files that can be signed. The default plug-in invokes the JAR Installation Manager (JIM) with this JAR file URL, rather than loading the URL into a window. PLUGINURL takes precedence over PLUGINSPAGE. It is recommended that you use PLUGINURL rather than PLUGINSPAG. Navigator 4.0 For an introduction to JIM, see the section Installing Composer Plug-ins in Chapter 2, Development Overview in the Composer Plug-in Guide. For more detailed information, see Using the JAR Installation Manager for Smart Update. ALIGN specifies the alignment for the embedded plug-in LEFT aligns text flush left (the default). RIGHT aligns text flush right. TOP aligns text to the top. BOTTOM aligns text to the bottom. BORDER="borderWidth" specifies the size, in pixels, of the border around the plug- in. FRAMEBORDER="NO" specifies that the plug-in has no border. HEIGHT="height" specifies the height of the area to be occupied by the plug-in. The units are determined by the UNITS attribute. The default is pixels. WIDTH="width" specifies the width of the area to be occupied by the plug-in. The output from the embedded file is scaled to fit the specified height and width. The units are determined by the UNITS attribute. The default is pixels. UNITS="units" defines the measurement unit used by the HEIGHT and WIDTH attributes. The value can be one of: pixels (the default) en (half the point size) HIDDEN="TRUE"|"FALSE" specifies whether the plug-in is visible on the page. A value of TRUE overrides any HEIGHT and WIDTH to set both the width and height of the area occupied by the output of the embedded file to zero. The default is FALSE. HSPACE="horizMargin" specifies a margin, in pixels, between the left and right edges of the plug-in and surrounding content. Navigator 1.1 VSPACE="vertMargin" specifies a margin, in pixels, between the top and bottom edges of the applet and surrounding content.Navigator 1.1 NAME="pluginName" specifies the name of the plug-in. The name can be used by JavaScript. PALETTE="FOREGROUND"|"BACKGROUND is relevant only on the Windows platform. A value of FOREGROUND makes the plug-in use the foreground palette. Similarly, a value of BACKGROUND makes the plug-in use the background palette, which is the default. Plug-in Example The following example embeds two objects, MyMovie.mov and Game.ids in the document. <NOEMBED> This page requires a web browser that can display objects. We recommend <I>Netscape Navigator</I>. </NOEMBED> <EMBED SRC="MyMovie.mov" WIDTH="150" HEIGHT="250" CONTROLS="TRUE"> <EMBED SRC="Game.ids" WIDTH="400" HEIGHT="300"> NOEMBED (alternative text for embedded objects) The NOEMBED tag specifies text to be displayed by browsers that cannot display content from plug-in programs. Browsers that can display plug-ins ignore all text in the NOEMBED tag. Syntax <NOEMBED>...</NOEMBED> Example See Plug-in Example. OBJECT (embedded object) The OBJECT tag can be used to embed a variety of object types in an HTML page. Among these types are plug-ins, Java components, ActiveX controls, applets, and images. OBJECT tag attributes determine the type of object to embed, including the type and location of the object's implementation (code) and the type and implementation of the object's data. Navigator 4.0 The OBJECT tag supports alternatove representations if the browser is not capable of supporting the object. The OBJECT tag can contain other HTML attributes, including other OBJECT tags, nested between its opening and closing tags. If the browser supports the object, it ignores all the nested HTML except the PARAM tags. If it does not support the object, it parses the nested HTML but ignores the OBJECT and PARAM tags. Syntax <OBJECT CLASSID="classFile" DATA="dataLocation" CODEBASE="classFileDir" TYPE="MIMEtype" ALIGN="alignment" HEIGHT="pixHeight" WIDTH="pixWidth" ID="name" > CLASSID="classFile" is the URL of the object implementation; this is similar to the CODE attribute of the APPLET tag. This URL is used by the Java Archive Installation Manager (JIM) if a plug-in is not installed or registered on the user's machine. Since CLASSID works like PLUGINURL for the object, it can use JIM to find and install a plug-in to handle the object. If there is no CLASSID attribute for an unhandled object, it is ignored, and the nested HTML (if any) is parsed. For an introduction to JIM, see the section Installing Composer Plug-ins in Chapter 2, Development Overview in the Composer Plug-in Guide. For more detailed information, see Using the JAR Installation Manager for Smart Update. DATA="dataLocation" is the URL of the object's data. CODEBASE="classFileDir" is the directory containing the object class file and any resources needed by the object. The value is a URL for an absolute or a relative pathname. An absolute URL is used as is without modification and is not affected by the document's BASE tag. A relative CODEBASE attribute is relative to the document's base URL defined by the BASE tag. If the document does not define a BASE tag, it is relative to the directory containing the HTML file. For OBJECT tags that are treated as plug-ins, CODEBASE is synonymous with the PLUGINSPAGE attribute of the EMBED tag. TYPE="MIMEtype" specifies the MIME type of the embedded object. HEIGHT, WIDTH, and ALIGN are basic IMG/APPLET/EMBED attributes. The HEIGHT and WIDTH attributes are required for OBJECT tags that resolve to EMBED tags. ID="name" is the name that JavaScript can use to refer to the object; this is equivalent to the NAME attribute of the APPLET and EMBED tags. It's up to you to provide enough attributes for the OBJECT tag and to make sure that they do not conflict; otherwise, the object cannot be embedded. When Netscape Navigator encounters an OBJECT tag, it goes through the tag's attributes, ignoring or parsing them as appropriate. It analyzes the attributes to determine the object type, then determines whether it can handle the type. If Netscape Navigator can handle the type, it parses the PARAM tags, and ignores all other HTML tags up to the closing </OBJECT> tag. If Netscape Navigator cannot determine or handle the type, it cannot embed the object, so it ignores the PARAM tags and parses the other HTML tags between <OBJECT> and </OBJECT>. Example The following example embeds an object, ticker.obj, in the document <OBJECT CODEBASE="classes" CLASSID="ticker.obj" DATA="data" WIDTH="150" HEIGHT="250"> [Contents] [Previous] [Next] [Alphabetical Tag List] [Index] Last Updated: 01/26/98 21:33:44 Copyright © 1998 Netscape Communications Corporation |