<!ELEMENT APPLET - - (PARAM*, (%text;)*)> <!ATTLIST APPLET CODEBASE CDATA #IMPLIED -- code base -- CODE CDATA #REQUIRED -- code file -- ALT CDATA #OPTIONAL -- alternate text -- NAME CDATA #IMPLIED -- applet name -- WIDTH NUMBER #REQUIRED HEIGHT NUMBER #REQUIRED ALIGN (left|right|top|texttop|middle| absmiddle|baseline|bottom|absbottom) baseline VSPACE NUMBER #IMPLIED HSPACE NUMBER #IMPLIED > <!ELEMENT PARAM - O EMPTY> <!ATTLIST PARAM NAME NAME #REQUIRED -- The name of the parameter -- VALUE CDATA #IMPLIED -- The value of the parameter -- >Applet resources (including their classes) are normally loaded relative to the document-URL (or <base> tag if it is defined). The codebase attribute is used to change this default behavior. If the codebase attribute is defined then it specifies a different location to find applet resources. The value can be an absolute URL or a relative URL. The absolute URL is used as is without modification and is not effected by the documents <base> tag. When the codebase attribute is relative, then it is relative to the document-URL (or <base> tag if defined).
<applet codebase="applets/NervousText" code=NervousText.class width=300 height=50> <param name=text value="Java is Cool!"> </applet>Which causes this to appear:
Applet resources are loaded relative to the codebase, including images, audio files, etc. However, the applet does have access to the document-URL if resources from that location are desired.
Here is an example of how applet code can reference a resource from the codebase (this should be used when resources are accessed that are referenced directly from within the applet code):
Image img = getImage(new URL(getBaseURL(), "images/cross.gif"));And here is an example of how applet code can reference a resource from the document-URL (this should be used when resources are accessed that are specified in an applet parameter, and which are therefore relative to the document's base):
Image img = getImage(new URL(getDocumentURL(), getParameter("src")));