Trail: Deployment
Lesson: Applets
Section: Deploying Applets
Deploying Applets in a Mixed-Browser Environment
Home Page > Deployment > Applets
Deploying Applets in a Mixed-Browser Environment

You can deploy applets for users of both Internet Explorer and the Mozilla family of browsers in one of two ways:

Using Pure HTML

When using a pure HTML approach to deploy applets in a mixed-browser environment, note the following:

Consider the following example code from an HTML page:

  <param name="code" value="Applet1.class">
      <embed code="Applet1.class"
          No Java Support.

Using JavaScript

Instead of using the pure HTML approach described above, you can use JavaScript to deploy applets in a mixed-browser environment.

Through JavaScript, you:

  1. Detect the user's browser through the appName variable.
  2. Use the document.write() method to write a tag based on the value of the appName variable:
    1. If the browser name equals "Netscape", write the embed tag.
    2. If the browser name equals "Microsoft Internet Explorer", write the object tag.

In the following example, the document.write() method outputs either an embed or object tag for each user “on the fly”:

<script language="Javascript">

  var _app = navigator.appName;

  if (_app == 'Netscape') {
    document.write('<embed code="Applet1.class"',
  else if (_app == 'Microsoft Internet Explorer') {
    document.write('<OBJECT ',
                   '<PARAM name="code" value="Applet1.class">',
  else {
    document.write('<p>Sorry, unsupported browser.</p>');


You can use the HTML Converter tool to help with generating object and embed tags for mixed environments.

Previous page: Using the embed Tag
Next page: Solving Common Applet Problems