BBS水木清华站∶精华区

发信人: Yapith (早起的鸟儿有食吃), 信区: Java        
标  题: Java Plugin使用说明---如何使用jdk1.2的applet(一) 
发信站: BBS 水木清华站 (Sat Sep 18 19:35:11 1999) 
 
老有网友问在jdk1.2下编写的applet如何使用的问题。因此贴一下这 
方面的资料。大家在SUN的主页上也是可以看到的。 
    因为时间的原因,没有翻译,直接给大家贴上的了。原文虽然 
很罗嗦,但不是很难懂。:-) 
    如果你只是关心如何让applet工作起来,本篇java plugin overview 
就可以不看了,直接去看第二篇就可以了。不过建议大家看看此文。 
 
Java Plug-in 1.2.2 Overview 
Introduction 
JavaTM Plug-in software from Sun Microsystems Inc. enables 
web page authors to direct Java applets or JavaBeansTM components 
on their intranet web pages to run using Sun's Java 2 Runtime 
Environment, Standard Edition (JRE), instead of the browser's 
default runtime. This release provides support for Microsoft 
Internet Explorer and Netscape Navigator on various Win32 platforms. 
Java Plug-in delivers full Java 2 SDK, Standard Edition v 1.2.2 
support for Internet Explorer and Navigator users. 
Java Plug-in is designed for enterprise customers who wish to 
deploy Java 2 SDK 1.2.2-based applets on their intranet web 
pages today. Specifically, web pages modified to support Java 
Plug-in enable users to run Java 2 SDK 1.2.2-based applets in 
Internet Explorer or Navigator. Java Plug-in integrates today's 
widely adopted web browsers with the benefits of all of the new 
features and capabilities of Java 2 SDK 1.2.2 
(see http://java.sun.com/products/jdk/1.2/docs/relnotes/ 
features.html for a list of new features found in Java 2 SDK 1.2.2). 
Java Plug-in is ready for the high-performance "Project Java(tm) 
HotSpot(tm)" virtual machine with a future-ready architecture. 
This means that when Sun adds new features or functionality to 
the Java 2 SDK, users can take full advantage of them in 
Internet Explorer and Navigator immediately by deploying the 
latest release of the Java Plug-in. This makes the process of 
upgrading all users in an enterprise to the latest Java 2 SDK 
feature set as easy as modifying one web page on your intranet. 
Java Plug-in Features 
Java Plug-in delivers several key capabilities to enterprises 
using Internet Explorer and Navigator: 
       Full Java 2 SDK 1.2.2 support: Enables enterprise 
developers to develop and deploy applets, taking full advantage 
of Java 2 SDK 1.2.2 features and functionality, such as JFC 1.1, 
JavaBeans enhancements and so on. 
       Future-ready Java 2 SDK Architecture: Java Plug-in features 
an architecture that makes it easy for Sun to bring new Java 2 SDK 
features and functionality, including those contained in the high 
performance Project Java HotSpot virtual machine, to Windows and 
Solaris desktops much more quickly than has been previously possible. 
       Free public download and easy install: Upon encountering a 
web page that specifies Java Plug-in, the browser will download and 
install all the necessary files and render the applet, requiring 
minimal user intervention. 
       Free Java Plug-in HTML Converter: Makes it easy and automatic 
for IS managers and web page authors to modify their HTML pages to 
specify the use of Java Plug-in rather than the browser's default 
Java runtime. 
Installing and Running the Java Plug-in 
The first time the web browser encounters a web page that specifies 
the use of the Java Plug-in, the browser must download and install 
the required files. System administrators can determine where users 
download Java Plug-in software; either from http://java.sun.com or 
from an internal server. Download and install times will vary 
depending on the type of network connection and overall system 
performance. Typical total download and installation times (over a 
local area network) will vary from three to ten minutes. In subsequent 
encounters of web pages that specify the use of the Java Plug-in, it 
is invoked instantaneously from the user's hard drive and the applet 
is rendered. 
Internet Explorer: When Internet Explorer first encounters a web page that s 
pecifies Java Plug-in, Internet Explorer will ask the user if it is OK to do 
wnload an ActiveX control that is digitally signed by Sun Microsystems, Inc. 
 and verifiable by the associated VeriSign Class 3 certificate. If the user  
says "Yes," Internet Explorer will quickly download a small ActiveX control  
from Sun's web site that will handle downloading the main Java Plug-in Activ 
eX control and Sun's JRE. This will include selecting the appropriate locale 
-specific JRE and offering the user a list of suitable download sites. It wi 
ll then download the files automatically and install them. The Java Plug-in  
ActiveX control will then run and use its parameters in the <OBJECT> tag to  
render the applet. The next time Internet Explorer encounters a web page tha 
t specifies the Java Plug-in, Internet Explorer will seamlessly load and run 
 the ActiveX control and JRE from the local disk, requiring no user interven 
tion. 
Netscape Navigator: When Navigator first encounters a web page that specifie 
s Java Plug-in, users will see a plugin-missing picture on the HTML page. Wh 
en the user clicks on this picture, Navigator will direct the user to the Ja 
va Plug-in download page. Users can then download the version of Java Plug-i 
n and install it. Once it is installed, Java Plug-in will then run and use i 
ts parameters in the <EMBED> tag to render the applet. The next time Navigat 
or encounters a web page that specifies the Java Plug-in, Navigator will sea 
mlessly load and run the plug-in and JRE from the local disk, requiring no u 
ser intervention. 
How the Java Plug-in Works 
The Java Plug-in does not replace or modify the browser's underlying Java ru 
ntime. Rather, it enables web page authors to specify the use of Sun's JRE i 
nstead of the default Java runtime for a given web page. This ensures enterp 
rise developers that Java 2 SDK 1.2.2-based applets are executed with full s 
upport for all of the features and capabilities of Java 2 SDK 1.2.2 (see htt 
p://java.sun.com/products/jdk/1.2/docs/relnotes/features.html for a list of  
new features found in Java 2 SDK 1.2.2. 
Internet Explorer: Java Plug-in leverages Internet Explorer's extension mech 
anisms in order to allow Sun's JRE to run inside Internet Explorer. The tech 
nology used to achieve this is Microsoft's COM/ActiveX. Using the HTML <OBJE 
CT> tag, web page authors can run ActiveX controls or COM components as part 
 of a web page. Internet Explorer provides elaborate mechanisms for download 
ing and caching ActiveX controls. This makes it possible for the web browser 
 to use Sun's JRE with minimal user intervention. 
Netscape Navigator: The Java Plug-in leverages Navigator's plug-in architect 
ure in order to allow Sun's JRE to run inside Navigator, much like users can 
 run QuickTime movies or Shockwave animations with plug-ins today. Using the 
 HTML <EMBED> tag, web page authors can cause plug-ins to be run as part of  
a web page. This makes it possible for the web browser to use Sun's JRE in N 
avigator. 
In order to utilize all of the features and capabilities of Java 2 SDK 1.2.2 
 in Internet Explorer or Navigator, web page authors must specify the use of 
 Sun's JRE using the Java Plug-in. Thus, web pages must be modified in order 
 to invoke Sun's JRE. Sun provides a written specification to guide web page 
 authors on how to make these changes. In addition, Sun provides the Java Pl 
ug-in HTML Converter, free of charge, that will automatically make the chang 
es to the selected set of HTML pages. 
Java Plug-in Documentation 
       Java Plug-in FAQ 
       Java Plug-in Documentation 
System Requirements 
The minimum system requirements for the Java Plug-in 
on Win32 are as follows: 
  - Windows 95, Windows 98 or Windows NT 4.0 
  - Internet Explorer 3.02 and higher, Navigator 3.0 and higher 
  - Pentium 90 MHz or faster processor 
  - 25 MB free hard disk space 
  - 16 MB (24 MB recommended) system RAM 
Java Plug-in works best over direct LAN (that is, Ethernet) 
connections. It will also function properly over dial-up 
modem (28.8 or faster). 
 
-- 
 
         世间有百媚千红  我独爱你那一种。  
 
 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: Software-Engine] 
发信人: Yapith (早起的鸟儿有食吃), 信区: Java        
标  题: java plugin的使用说明--- (二) 
发信站: BBS 水木清华站 (Sat Sep 18 19:42:50 1999) 
 
本篇是讲述如何用特殊的tag写一个可以让java plugin辨认的applet代码的。 
哦,忘记说明了。所谓java plugin就是jre1.2(java runtime envirnment). 
客户方只要安装了它就可以运行jdk1.2编写的applet了。当然,你的嵌入 
applet的页面必须按照本文所说的方式引用applet.就是用特殊的tag告诉 
浏览器:这是个jdk1.2的applet,请使用java plugin来解释执行它。 
我把它从SUN荡下来,在 166.111.4.80 和 ftp.cs.pku.edu.cn上各放了一份。 
 
JAVATM PLUG-IN HTML SPECIFICATION 
 
*Introduction 
*JavaTM Plug-in in IE on Windows 95, Windows 98 
 or Windows NT 4.0 operating environments 
*Java Plug-in in NavigatorTM on Windows 95, 
Windows 98, Windows NT 4.0, or SolarisTM operating 
 environments 
* Java Plug-in in IE and Navigator 
* Java Plug-in Anywhere 
* Summary 
***Introduction 
 JavaTM Plug-in is a product from Sun Microsystems, 
Inc. that runs beans or applets written in the Java 
programming language in an HTML page using Sun's 
Java virtual machine (JVM). To launch Java Plug-in 
when IE or Netscape NavigatorTM browses an HTML 
page, use the OBJECT tag and the EMBED tag in the 
HTML specification. 
This document explains the OBJECT tag and EMBED tag 
styles required in Java Plug-in. It is intended for 
users who want to manually insert Java Plug-in tags 
in their HTML pages. There is a Java Plug-in HTML 
Converter available free-of-charge from Sun Microsystems 
that automatically does this for you. 
The tag style described in this document has been 
designed to work in the future when new browsers 
are released on Windows 98, Windows NT 5.0 and 
future versions of Solaris operating systems. 
The information in this specification has been 
tested on various platforms. 
Details 
Applets are in wide use today on the Internet. 
They are normally specified in an HTML file as 
follows: 
<APPLET code="XYZApp.class" codebase="html/" 
align="baseline" width="200" height="200"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET> 
 
Normally, an APPLET tag specifies the information 
about the applet and the <PARAM> tags between the 
<APPLET> and </APPLET> tag store the per-instance 
applet information. 
Because an APPLET tag is rendered by the browser, 
there is no easy way to interrupt the browser and 
use Sun's JVM to run the applet. Instead, to use 
Java Plug-in, you must use the Java Plug-in tag 
(OBJECT or EMBED) in place of the APPLET tag in 
an HTML page. 
Java Plug-in in IE on Windows 95, Windows 98 or 
Windows NT 4.0 
To use Java Plug-in in IE on Windows 95, Windows 
98 or Windows NT 4.0, use the OBJECT tag. The 
following is an example of mapping an APPLET tag 
to a Java Plug-in tag: 
Original APPLET tag: 
<APPLET code="XYZApp.class" codebase="html/" align="baseline" 
    width="200" height="200"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET> 
New OBJECT tag: 
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
    codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
    <PARAM NAME="code" VALUE="XYZApp.class"> 
    <PARAM NAME="codebase" VALUE="html/"> 
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
        No JDK 1.2 support for APPLET!! 
</OBJECT> 
 
  Note that the OBJECT tag contains similar information to 
the APPLET tag. It is sufficient to launch Java Plug-in in 
IE. The classid in the OBJECT tag is the class identifier 
for Java Plug-in itself. This class identifier should be 
the same in every HTML page. When IE renders this class 
identifier in the OBJECT tag, it will try to load Java Plug-in 
into the browser. 
There are several attributes in the OBJECT tag, such as width, 
height and align, that are mapped directly from the corresponding 
attributes in the APPLET tag. These contain formatting information 
that IE will use to position Java Plug-in. Since this information 
is mapped directly without changes, the position and appearance of 
the applets using Java Plug-in should be the same as those applets 
using the APPLET tag. 
Not all attributes in the APPLET tag can be mapped to the OBJECT 
tag attributes. For example, the attributes code and codebase in 
the APPLET tag are not mapped into the OBJECT tag attribute. 
Instead, the attribute code is mapped into the PARAM code because, 
according to the HTML specification, the attribute code does not 
exist in the OBJECT tag. There are other attributes that do not 
correspond in the OBJECT tag attributes. These attributes, with 
one exception, should be mapped to PARAM tags. 
The one exception is the codebase attribute. In the APPLET tag, 
the codebase attribute represents the location from which to 
download additional class and jar files. However, in the OBJECT 
tag, the codebase attribute represents the location from which 
to download Java Plug-in when it is not found on the local machine. 
Because the codebase attribute has two different meanings in the 
APPLET and OBJECT tags, you must resolve this conflict by mapping 
this attribute into a PARAM codebase in the OBJECT tag. 
In the above example, the code and codebase attributes in the APPLET 
tag are mapped into the OBJECT tag parameters. The PARAM code 
identifies the applet, and its value should be the same as the 
code attribute in the APPLET tag. The PARAM codebase identifies 
the codebase of the applet. Java Plug-in knows where to download 
the applet or JavaBeans component because it can read this 
information from the parameters. The parameter type is not 
mapped from the APPLET tag, but it is required in the OBJECT tag. 
It identifies the type of the Java executable, such as an applet 
or a JavaBean, so Java Plug-in knows how to initialize the Java 
executable. These three PARAM tags (code, codebase, and type) in 
the above example are specified by Java Plug-in. They do not exist 
in the PARAM of the original APPLET tag. Note that the model 
parameter within the OBJECT tag is identical to the model parameter 
inside the APPLET tag. Except for these first three parameters 
specified for Java Plug-in, the remainder of the parameters are 
the same as those inside the APPLET tag. 
The text "No JDK 1.2 support for APPLET!!" in the APPLET tag is 
mapped inside the <OBJECT> and </OBJECT> tags. Originally, this 
text is displayed only if the browser does not have Java support. 
By mapping it inside the OBJECT tag, this text will displayed if 
the browser does not support the OBJECT tag. 
The APPLET-OBJECT tag attributes mapping is as follows: 
 
Attributes APPLET tag support OBJECT tag support Attribute map 
in OBJECT tag 
ALIGN X X Attribute ALIGN 
ALT X 
ARCHIVE X   Param archive 
CODE X X Param code 
CODEBASE X X Param codebase 
HEIGHT X X Attribute HEIGHT 
HSPACE X X Attribute HSPACE 
NAME X X Attribute NAME, Param NAME 
OBJECT X   Param object 
TITLE X X Attribute TITLE 
VSPACE X X Attribute VSPACE 
WIDTH X X Attribute WIDTH 
MAYSCRIPT X X Param MAYSCRIPT 
 
  Some attributes are special to the OBJECT tag. These 
attributes are: 
 
  Meaning in OBJECT tag 
Attribute CLSID It should always have the same value. 
i.e. "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93". 
Attribute CODEBASE It should be a full URL pointing to a 
CAB file somewhere on the network. It should, by default, 
point to a page on the Java Software web site. 
Param type If it is a Java applet, the value should be 
"application/x-java-applet;version=1.2" or "application/x-java-applet". 
If it is a JavaBeans component, the value should be 
"application/x-java-bean;version=1.2" or "application/x-java-bean". 
Param codebase Specifies the base URL of the applet. Relative URL 
to the document should be used. This attribute is optional. 
Param code Specifies the name of the Java applet or JavaBeans component. 
It cannot be used with param object inside the same OBJECT tag. 
Param object Specifies the name of the serialized Java applet or 
JavaBeans component. It cannot be used with param code inside the 
same OBJECT tag. This attribute is optional. Param archive Specifies 
the name of the Java archive. This attribute is optional. 
Param mayscript Specifies whether the applet is allowed to access 
netscape.javascript.JSObject. The value can be either "true" or 
"false". This attribute is optional. 
 
  Note that if the original APPLET tag has PARAM type, codebase, 
  code, object or archive, mapping it to the OBJECT tag will 
  cause a problem because duplicate param names will occur. 
  To avoid this, Java Plug-in also supports another set of param 
  names, as follows: 
Original Param Names New Param Names 
code java_code 
codebase java_codebase 
archive java_archive 
object java_object 
type java_type 
You should use these new param names only when necessary. 
If both the new and original param names exist in the same 
OBJECT tag, the value associated with the new param name 
is always used by Java Plug-in to load the applet or JavaBean. 
Java Plug-in in Netscape Navigator on Windows 95, Windows 
98, Windows NT 4.0, or SolarisTM operating environments 
To use Java Plug-in in Netscape Navigator 3 or 4 on 
Windows 95, Windows 98, Windows NT 4.0, or Solaris operating 
environments, use the EMBED tag. The following example maps 
an APPLET tag to a Java Plug-in EMBED tag: 
Original APPLET tag: 
 
<APPLET code="XYZApp.class" codebase="html/" align="baseline" 
    width="200" height="200"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET> 
 
  New EMBED tag: 
 
<EMBED type="application/x-java-applet;version=1.2" width="200" 
   height="200" align="baseline" code="XYZApp.class" 
   codebase="html/" model="models/HyaluronicAcid.xyz" 
   pluginspage="">http://java.sun.com/products/plugin/1.2/plugin-install.html"> 
<NOEMBED> 
   No JDK 1.2 support for APPLET!! 
</NOEMBED> 
</EMBED> 
 
 
  Note that the EMBED tag contains similar information to the APPLET 
tag, and it is sufficient to launch Java Plug-in in Navigator. The 
attribute type in the EMBED tag is used for identifying the type of 
the Java programming language executable, such as an applet or a 
bean. When Navigator renders this attribute in the EMBED tag, it 
will try to load Java Plug-in into the browser. By specifying the 
type attribute, Java Plug-in will know how to initialize the Java 
programming language executable. 
In the above example, several attributes in the EMBED tag, such 
as width, height and align, map directly from the corresponding 
attributes in the APPLET tag. These contain formatting information 
that Navigator uses to position Java Plug-in. Since this information 
is mapped directly without changes, the position and appearance of 
the applets using Java Plug-in should be the same as those applets 
using the APPLET tag. 
Unlike the OBJECT tag, all information must be stored inside the 
<EMBED> tag instead of using PARAM. Therefore, all attributes and 
params in the APPLET tag must be mapped as attribute-value pairs 
inside the EMBED tag. 
In the above example, the code and codebase attributes in the 
APPLET tag are mapped into the EMBED tag attributes. Attribute 
code identifies the applet. Its value should be the same as the 
code attribute in the APPLET tag. Attribute codebase identifies 
the codebase of the applet. Java Plug-in knows where to download 
the applet or JavaBeans component because it can read this 
information from the attributes. Also notice that the model 
attribute within the EMBED tag is mapped from the model param 
inside the APPLET tag. 
Like the codebase attribute in the OBJECT tag, attribute 
pluginspage in the EMBED tag is used by Navigator if Java 
Plug-in is not installed. It should always point to the Java 
Plug-in Download Page on the Java Software web site. 
The text "No JDK 1.2 support for APPLET!!" in the APPLET tag 
is mapped inside the <NOEMBED> and </NOEMBED> tags. Originally, 
this text is displayed only if the browser does not have Java 
technology support. By mapping it inside the NOEMBED tag, this 
text will be displayed if the browser does not support the EMBED 
tag or if Navigator fails to start the Java Plug-in. 
The APPLET-EMBED tag attributes mapping is as follows: 
 
Attributes APPLET tag support EMBED tag support Attribute map in EMBED tag 
ALIGN X X Attribute ALIGN 
ALT X X Attribute ALT 
ARCHIVE X   Attribute archive 
CODE X   Attribute code 
CODEBASE X   Attribute codebase 
HEIGHT X X Attribute HEIGHT 
HSPACE X X Attribute HSPACE 
NAME X X Attribute NAME 
OBJECT X   Attribute object 
TITLE X X Attribute TITLE 
VSPACE X X Attribute VSPACE 
WIDTH X X Attribute WIDTH 
MAYSCRIPT X X Attribute MAYSCRIPT 
 
  Some attributes are special to the EMBED tag. These attributes are: 
 
  Meaning in EMBED tag 
Attribute type If it is an applet, the value should be 
"application/x-java-applet;version=1.2" or "application/x-java-applet". 
If it is a bean, the value should be 
"application/x-java-bean;version=1.2" or "application/x-java-bean". 
Attribute codebase Specifies the base URL of the applet. 
This attribute is optional. 
Attribute code Specifies the name of the Java applet or JavaBeans 
component. It cannot be used with param object inside the same 
EMBED tag. 
Attribute object Specifies the name of the serialized Java applet 
 or JavaBeans component. It cannot be used with param code inside 
 the same EMBED tag. This attribute is optional. 
Attribute archive Specifies the name of the Java archive. 
This attribute is optional. 
Attribute pluginspage It should be a full URL pointing to an 
HTML page somewhere on the network. 
Attribute mayscript Specifies whether the applet is allowed to 
access netscape.javascript.JSObject.  The value can be either 
"true" or "false". This attribute is optional. 
 
  Similar to the OBJECT tag case, if the original APPLET tag 
has PARAM type, codebase, code, object, or archive, mapping 
it to the EMBED tag attribute will cause a problem. To avoid 
this, Java Plug-in also supports the same new set of attribute 
names, as follows: 
Original Attribute Names New Attribute Names 
code java_code 
codebase java_codebase 
archive java_archive 
object java_object 
type java_type 
You should use these new attribute names only necessary. 
If both new and original attribute names exist in the same 
EMBED tag, the value associated with the new attribute name 
is always used by Java Plug-in to load the applet or bean. 
Java Plug-in in IE and Navigator 
The OBJECT tag in IE and the EMBED tag in Navigator allows 
your HTML page to use Java Plug-in if the HTML page is browsed 
on Windows 95, Windows 98, Windows NT 4.0, or Solaris operating 
environments. However, if the HTML page is on the Internet/intranet, 
the page is likely to be browsed by both IE and Navigator. 
You should activate the Java Plug-in if both Navigator and 
IE will browse the same HTML page. You can do this using the 
Java Plug-in OBJECT tag, as follows: 
Original APPLET tag: 
<APPLET code="XYZApp.class" codebase="html/" align="baseline" 
    width="200" height="200"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET> 
New OBJECT tag: 
 
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
    codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
<PARAM NAME="code" VALUE="XYZApp.class"> 
<PARAM NAME="codebase" VALUE="html/"> 
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.2"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
<COMMENT> 
    <EMBED type="application/x-java-applet;version=1.2" width="200" 
       height="200" align="baseline" code="XYZApp.class" 
       codebase="html/" model="models/HyaluronicAcid.xyz" 
       pluginspage="http://java.sun.com/products/plugin/1.2/ 
plugin-install.html"> 
    <NOEMBED> 
    </COMMENT> 
           No JDK 1.2 support for APPLET!! 
    </NOEMBED></EMBED> 
</OBJECT> 
 
  Because IE understands the <OBJECT> tag, it will try to 
launch Java Plug-in. Notice that the <COMMENT> tag is a 
special HTML tag understood only by IE. IE ignores text 
between the <COMMENT> and </COMMENT> tags. In effect, the 
above tags actually become: 
 
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
    codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
    <PARAM NAME="code" VALUE="XYZApp.class"> 
    <PARAM NAME="codebase" VALUE="html/"> 
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
        No JDK 1.2 support for APPLET!! 
    </NOEMBED></EMBED> 
</OBJECT> 
 
  This is identical to the OBJECT tag example outlined above. 
The </NOEMBED> and </EMBED> tags are ignored by the OBJECT tag 
because there are no corresponding <NOEMBED> and <EMBED> tags. 
Because Navigator does not understand the OBJECT and COMMENT 
tags, Navigator 3/4 on the Windows 95, Windows 98, Windows NT 
4.0, or Solaris operating environments reads the above tags 
as follows: 
<EMBED type="application/x-java-applet;version=1.2" width="200" height="200" 
    align="baseline" code="XYZApp.class" codebase="html/" 
    model="models/HyaluronicAcid.xyz" 
    pluginspage="">http://java.sun.com/products/plugin/1.2/plugin-install.html"> 
<NOEMBED> 
    No JDK 1.2 support for APPLET!! 
</NOEMBED> 
</EMBED> 
 
  This is identical to the EMBED tag example outlined above. 
  Navigator 3/4 ignores <COMMENT> and </COMMENT> tags because 
  they are an HTML extension in IE only. 
This example illustrates that you can use the combined 
OBJECT-EMBED tag to activate Java Plug-in in the browser 
if either IE or Navigator is used. This combined tag is strongly 
recommended unless your HTML page is browsed by users in a 
homogeneous environment. The Java Plug-in HTML Converter from 
Sun Microsystems automatically converts HTML pages into this 
tag style for you. 
Java Plug-in Anywhere 
In an Internet/intranet environment, an HTML page is likely to 
be seen by browsers on different platforms. You should activate 
Java Plug-in only on the right browser and platform combination. 
Otherwise, you should use the browser's default JVM. You can 
achieve this using the following Java Plug-in tag: 
Original APPLET tag: 
<APPLET code="XYZApp.class" codebase="html/" align="baseline" 
    width="200" height="200"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET> 
New style tag: 
The following is an example of an equivalent Java Plug-in tag. 
This example includes comments. 
<!-- The following code is specified at the beginning of the <BODY> tag. --> 
<SCRIPT LANGUAGE="JavaScript"><!-- 
    var _info = navigator.userAgent; var _ns = false; 
    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 
        && _info.indexOf("Windows 3.1") < 0); 
//--></SCRIPT> 
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- 
    var _ns = (navigator.appName.indexOf("Netscape") >= 0 
        && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 
        && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) 
        || _info.indexOf("Sun") > 0)); 
//--></SCRIPT></COMMENT> 
<!-- The following code is repeated for each APPLET tag --> 
<SCRIPT LANGUAGE="JavaScript"><!-- 
    if (_ie == true) document.writeln(' 
<OBJECT 
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
    <NOEMBED><XMP>'); 
    else if (_ns == true) document.writeln(' 
<EMBED 
    type="application/x-java-applet;version=1.2" width="200" height="200" 
    align="baseline" code="XYZApp.class" codebase="html/" 
    model="models/HyaluronicAcid.xyz" 
    pluginspage="">http://java.sun.com/products/plugin/1.2/plugin-install.html"> 
    <NOEMBED><XMP>'); 
//--></SCRIPT> 
   <APPLET code="XYZApp.class" codebase="html/" align="baseline" 
        width="200" height="200"> 
</XMP> 
    <PARAM NAME="java_code" VALUE="XYZApp.class"> 
    <PARAM NAME="java_codebase" VALUE="html/"> 
    <PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET></NOEMBED></EMBED> 
</OBJECT> 
<!-- 
    <APPLET code="XYZApp.class" codebase="html/" align="baseline" 
        width="200" height="200"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
    </APPLET> 
--> 
 
  Although this tag seems complicated compared to the old APPLET 
tag, it is not. Most of the Java Plug-in tag is the same regardless 
of the applet used. For the majority of cases, a webmaster can copy 
and paste the Java Plug-in tag. 
The first block of the script extracts the browser and platform. You 
must determine the browser and platform on which the applet is running. 
You do this by using JavaScriptTM to extract first the browser name, 
then the platform. This is done once per HTML document. 
The second block of the script replaces the APPLET tag. You must 
replace each APPLET tag with a similar block of code. The script 
replaces the APPLET tag with either an EMBED tag or OBJECT tag, 
depending on the browser. You use the OBJECT tag for IE and the 
EMBED tag for Netscape Navigator. Finally, the original APPLET tag 
is included as a comment at the end. It is always a good idea to 
keep the original APPLET tag in case you want to remove the Java 
Plug-in invocation. 
The first JavaScript establishes the browser and the platform on 
which the browser is running. You must do this because, currently, 
Java Plug-in supports only Windows 95, Windows 98, Windows NT 4.0, 
and Solaris. Note that Windows NT 3.51 is the only Win32 platform 
that Java Plug-in does not support. Java Plug-in should be invoked 
only on the supported browser and platform. The script sets the 
variable _ie to true if the browser is Internet Explorer. It sets 
the variable _ns to true if the browser is Navigator. (Note that 
all variable names in the JavaScript start with "_". This is done 
to avoid conflicting with other JavaScript variables in the same 
page.) 
To detect the right browser, the JavaScript evaluates three strings 
that are within the JavaScript's Navigator object: userAgent, 
appVersion, and appName. These strings contain information about 
the browser and the platform. By looking at some examples of the 
string userAgent, you can see how to evaluate userAgent and use it 
to determine the browser. The following are some examples of the 
userAgent string for different platforms as it appears in Internet 
Explorer. 
Platform and Browser JavaScript's Navigator.userAgent string 
Windows NT 4.0 w/IE 4.0 "Mozilla/4.0 (compatible; MSIE 4.0; Windows NT)" 
Windows NT 4.0 w/IE 3.02 "Mozilla/2.0 (compatible; MSIE 3.02; Windows NT)" 
Windows 95 w/IE 4.0 "Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)" 
Windows 95 w/IE 3.02 "Mozilla/2.0 (compatible; MSIE 3.02; Windows 95)" 
Windows NT 3.51 w/IE 4.0 "Mozilla/4.0 (compatible; MSIE 4.0; Windows 3.1)" 
Windows 3.1 w/IE 4.0 "Mozilla/4.0 (compatible; MSIE 4.0; Windows 3.1)" 
Windows NT 4.0 w/Navigator 4.04 "Mozilla/4.04 [en] (WinNT; I)" 
Windows NT 4.0 w/Navigator 3.04 "Mozilla/3.04 (WinNT; I)" 
Windows NT 3.51 w/Navigator 4.04  "Mozilla/4.04 [en] (WinNT; I)" 
Windows NT 3.51 w/Navigator 3.04  "Mozilla/3.04 (WinNT; I)" 
Windows 95 w/Navigator 4.03 "Mozilla/4.03 [en] (Win95; I)" 
Windows 95 w/Navigator 3.03 "Mozilla/3.03 (Win95; I)" 
Solaris 2.6 w/Navigator 4.02 "Mozilla/4.02 [en] (X11; l; SunOS 5.6 sun4u) 
/*  此处删去了一个表格。 */ 
  The above table shows that only Windows 95 and Windows NT 4.0 with IE 
can pass the Java Plug-in browser and platform requirements. However, 
this logic makes no assumptions about future releases of IE or future 
releases of Windows with IE. As long as the userAgent string contains 
"MSIE" and "Win", the above code should work in future releases of 
IE on Win32. 
The above logic summarizes into the following: 
 
<SCRIPT LANGUAGE="JavaScript"><!-- 
    var _info = navigator.userAgent; 
    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 
            && _info.indexOf("Windows 3.1") < 0); 
//--></SCRIPT> 
 
  It is harder to detect Navigator on the right platform. Using just 
JavaScript, there is no way to determine if the browser is running 
on the Windows NT 3.51 or Windows NT 4.0 operating platform. (Refer 
to the above table and examine the userAgent string. Notice that 
the userAgent strings in Windows NT 3.51 and Windows NT 4.0 operating 
platforms are the same in Navigator.) It is important to make this 
distinction because Java Plug-in supports only the Windows NT 4.0 
operating platform. To run Java Plug-in on the right platform, you 
must use LiveConnect in Navigator to determine the OS version number. 
This can be summarized as follows: 
/* 此处删去一个表格。*/ 
 
  The above logic translates into the following code: 
<SCRIPT LANGUAGE="JavaScript"><!-- 
    var _info = navigator.userAgent; var _ns = false; 
//--></SCRIPT> 
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- 
     var _ns = (navigator.appName.indexOf("Netscape") >= 0 
            && ((_info.indexOf("Win") > 0  && _info.indexOf("Win16") < 0 
            && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) 
            || _info.indexOf("Sun") > 0)); 
//--></SCRIPT></COMMENT> 
 
  Referring to the previous table, note that only Windows 95, Windows NT 
4.0, and Solaris operating environments with Navigator pass all the tests. 
Because LiveConnect is used to get the OS version number and only Navigator 
supports LiveConnect, a JavaScript that accesses LiveConnect will not be 
understood by IE. To prevent this from causing a problem, you block out 
this piece of the script using the COMMENT tag since COMMENT is an 
IE-specific comment tag. The text between the COMMENT tag is ignored 
by IE but not by Navigator. In addition, you must specify the script 
language as JavaScript1.1 to block this out if the browser is Navigator 2. 
At this point, the above logic for IE and Navigator summarizes to a script 
that should look as follows: 
 
<!-- The following code is specified at the beginning of the <BODY> tag. --> 
<SCRIPT LANGUAGE="JavaScript"><!-- 
    var _info = navigator.userAgent; var _ns = false; 
    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 
            && _info.indexOf("Windows 3.1") < 0); 
//--></SCRIPT> 
<COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!-- 
    var _ns = (navigator.appName.indexOf("Netscape") >= 0 
           && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 
           && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) 
           || _info.indexOf("Sun") > 0)); 
//--></SCRIPT></COMMENT> 
  Remember that this block of JavaScript should be put at the top of the 
<BODY> of the HTML file. It is put at the top so that other JavaScripts 
can reference the variables _ie and _ns. This JavaScript is the same in 
all HTML files, and it is only needed once for each HTML body. 
The second block of HTML tags are actually the corresponding OBJECT 
and EMBED tags that are mapped from the data in the APPLET tag. Note 
that JavaScript outputs the OBJECT tag when the browser is IE running 
on the Windows 95, Windows 98 or Windows NT 4.0 operating environments. 
If the browser is Navigator 3/4 on Windows 95, Windows 98, Windows NT 
4.0, or Solaris operating environments, then JavaScript also outputs 
the EMBED tag, though with a slightly different syntax. Recall that the 
mechanism for detecting the browser and the platform has been described 
in the above section. (Tags <!-- and --> are used for comments in HTML.) 
Original APPLET tag: 
<APPLET code="XYZApp.class" codebase="html/" align="baseline" 
    width="200" height="200"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET> 
New style tag: 
 
<SCRIPT LANGUAGE="JavaScript"><!-- 
    if (_ie == true) document.writeln('<OBJECT 
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
    <NOEMBED><XMP>'); 
    else if (_ns == true) document.writeln('<EMBED 
    type="application/x-java-applet;version=1.2" width="200" height="200" 
    align="baseline" code="XYZApp.class" codebase="html/" 
    model="models/HyaluronicAcid.xyz" 
    pluginspage="">http://java.sun.com/products/plugin/1.2/plugin-install.html"> 
    <NOEMBED><XMP>'); 
//--></SCRIPT> 
    <APPLET code="XYZApp.class" codebase="html/" align="baseline" 
        width="200" height="200"></XMP> 
    <PARAM NAME="java_code" VALUE="XYZApp.class"> 
    <PARAM NAME="java_codebase" VALUE="html/"> 
    <PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
        No JDK 1.2 support for APPLET!! 
    </APPLET></NOEMBED></EMBED></OBJECT> 
 
  Note that the original APPLET tag is also mapped in the new Java 
Plug-in tag. This is done because Java Plug-in is intended to be used 
only on supported platforms. Leaving the APPLET tag in the script 
ensures that browsers that do not support Java Plug-in, or browsers 
that do not support JavaScript can gracefully handle the applet using 
the default JVM. HotJava Browser, IE, and Navigator on non-Java Plug-in 
supported platforms, or browsers without JavaScript support, read the 
above tags as follows: 
<APPLET code="XYZApp.class" codebase="html/" align="baseline" 
    width="200" height="200"></XMP> 
<PARAM NAME="java_code" VALUE="XYZApp.class"> 
<PARAM NAME="java_codebase" VALUE="html/"> 
<PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.2"> 
<PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
    No JDK 1.2 support for APPLET!! 
</APPLET></NOEMBED></EMBED></OBJECT> 
 
  These browsers ignore the tags </XMP>, </OBJECT>, </EMBED>, and 
</NOEMBED> as well because there is no corresponding <XMP>, <OBJECT>, 
<EMBED>, and <NOEMBED> tags. Because Java Plug-in is targeted for 
features in the JDK 1.2 or future releases, those browsers without 
full JDK 1.2 support and who do not support Java Plug-in will display 
the message "No JDK 1.2 support for APPLET". 
Unlike the previous examples, the mapped PARAM names contain java_code, 
java_codebase, and java_type instead of code, codebase, and type. This 
is necessary because specifying code and codebase in the <PARAM> inside 
the <APPLET> and </APPLET> tag causes problems in some browsers. 
IE on Windows 95, Windows 98 or Windows NT 4.0 reads the tags as follows: 
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
    <NOEMBED><XMP> 
    <APPLET code="XYZApp.class" codebase="html/" align="baseline" 
        width="200" height="200"></XMP> 
    <PARAM NAME="java_code" VALUE="XYZApp.class"> 
    <PARAM NAME="java_codebase" VALUE="html/"> 
    <PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
        No JDK 1.2 support for APPLET!! 
    </APPLET></NOEMBED></EMBED> 
</OBJECT> 
 
  Be careful when you use the <XMP> tag. Because IE renders the <OBJECT> 
tag, you must disable the <APPLET> tag. If not disabled, two applets 
will simultaneously show up in the browser--one applet will be running 
in Microsoft's JVM, and the other will be running in Sun's JVM using 
Java Plug-in. The <XMP> tag provides a solution. The <XMP> and </XMP> 
tags basically transform any HTML tag that occurs between them into a 
stream of static text. In the above example, the <XMP> and </XMP> tags 
cause the browser to treat the <APPLET> tag as static text instead of 
an HTML tag. Because the browser ignores any static text between the 
<OBJECT> tag and the <PARAM> tag, the above tags actually become: 
<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
    width="200" height="200" align="baseline" 
codebase="http://java.sun.com/products/plugin/1.2/ 
jinstall-12-win32.cab#Version=1,2,0,0"> 
    <PARAM NAME="java_code" VALUE="XYZApp.class"> 
    <PARAM NAME="java_codebase" VALUE="html/"> 
    <PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
        No JDK 1.2 support for APPLET!! 
</OBJECT> 
 
  This is identical to the OBJECT tag example outlined above. Note that 
the <OBJECT> tag ignores the <NOEMBED>, </NOEMBED>, and </EMBED> tags. 
Navigator 3/4 on Windows 95, Windows 98 or Windows NT 4.0 operating 
environments reads tags as follows: 
<EMBED type="application/x-java-applet;version=1.2" width="200" height="200" 
    align="baseline" code="XYZApp.class" codebase="html/" 
    model="models/HyaluronicAcid.xyz" 
    pluginspage="">http://java.sun.com/products/plugin/1.2/plugin-install.html"> 
<NOEMBED><XMP> 
    <APPLET code="XYZApp.class" codebase="html/" align="baseline" 
        width="200" height="200"></XMP> 
    <PARAM NAME="java_code" VALUE="XYZApp.class"> 
    <PARAM NAME="java_codebase" VALUE="html/"> 
    <PARAM NAME="java_type" VALUE="application/x-java-applet;version=1.2"> 
    <PARAM NAME="model" VALUE="models/HyaluronicAcid.xyz"> 
        No JDK 1.2 support for APPLET!! 
    </APPLET></NOEMBED></EMBED></OBJECT> 
  Note that the <XMP> tag is used again in the <EMBED> tag to also 
  disable the <APPLET> tag. The <EMBED> tag ignores the <PARAM> and 
  </OBJECT> tags as well. In effect, the above tags actually become: 
<EMBED type="application/x-java-applet;version=1.2" width="200" height="200" 
    align="baseline" code="XYZApp.class" codebase="html/" 
    model="models/HyaluronicAcid.xyz" 
    pluginspage="">http://java.sun.com/products/plugin/1.2/plugin-install.html"> 
<NOEMBED> 
        No JDK 1.2 support for APPLET!! 
</NOEMBED> 
</EMBED> 
 
  This is identical to the EMBED tag example outlined above. 
You can use the combined OBJECT-EMBED-JavaScript tag to activate Java Plug-in 
in the right browser on the right platform. This combined tag is complicated 
and it should be used only if your HTML page is browsed by users in a 
heterogenous environment. 
Summary 
This document describes the OBJECT tag and EMBED tag styles used by Java 
Plug-in. It focuses on the conversion from an APPLET tag to the OBJECT 
and EMBED tags. Currently, HTML 4.0 suggests that the OBJECT tag is the 
best way to insert Java applets and JavaBeans components into a HTML page. 
This document will be updated in the near future should there be a need to 
convert the OBJECT tag to the Java Plug-in tag style. Information disclosed 
in this document is intended to assist ISVs for writing HTML migration tools 
and to assist webmasters with Java Plug-in migration. The tag style described 
in this document is subject to change in the future. 
Note that the use of Java Plug-in is not limited to the tag styles described 
in this document. In fact, webmasters are encouraged to modify the tag style 
or mix the tag with JavaScript to fit their needs. As long as the described 
OBJECT tag is used in IE and EMBED tag is used in Navigator, there should be 
no problems running Java Plug-in. Currently, there are several conversion 
templates shipped with the Java Plug-in HTML converter. Webmasters may find 
one template better than others for their needs, and are encouraged to 
modify these templates themselves if necessary. 
 
 
-- 
 
         世间有百媚千红  我独爱你那一种。  
 
 
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: Software-Engine] 

BBS水木清华站∶精华区