How should I put an applet in a strict HTML page?

Discussion in 'HTML' started by Christopher J. Henrich, Dec 22, 2004.

  1. I am trying to prepare web pages that contain applets. The old way,
    which uses the <applet> tag, has been deprecated for a long time, and
    is rejected if the web page is declared to be strict HTML. The new,
    correct, way that is supposed to be portable across browsers is to use
    an <object> tag.

    The exact details of how to use an object tag are not completely
    spelled out, anywhere that I have found. Mostly, one finds examples of
    "this works for me." Well, here is a sample that does work for me, on
    several Mac browsers.
    <object
    classid="java:XXXXX.class"
    codetype="application/octet-stream"
    data="java"XXXXX.class"
    type="application/x-java-applet"
    archive="YYYYY.jar"
    width = "500"
    height = "300" >
    </object>

    Here, "XXXXX" should be the name of the principal class in the applet
    (probably an extension of Applet or JApplet), and "YYYYY.jar" should be
    a path to the archive file; I make this path be relative to the
    location of the HTML file, but I think it could be a general URL .

    I have tested this successfully with Safari, Camino, Mozilla, Netscape,
    and Firefox. My test fails o iCab; I think there are serious problems
    with CSS and layout that may have interfered.

    I welcome criticism, and information on whether this markup is OK for
    Windows browsers.

    --
    Chris Henrich
    The total lack of evidence is the surest sign that the conspiracy is working.
     
    Christopher J. Henrich, Dec 22, 2004
    #1
    1. Advertising

  2. On Wed, 22 Dec 2004 18:19:45 GMT, Christopher J. Henrich
    <> wrote:

    [snip]

    > The exact details of how to use an object tag are not completely spelled
    > out, anywhere that I have found.


    Sun have produced a document that discusses applet inclusion within a Web
    page
    (<URL:http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/using_tags.html>)
    but it refers to the EMBED element when discussing Netscape. The proposed
    OBJECT syntax only works for IE and Opera.

    [snip]

    > Well, here is a sample that does work for me, on several Mac
    > browsers.
    > <object
    > classid="java:XXXXX.class"
    > codetype="application/octet-stream"
    > data="java"XXXXX.class"
    > type="application/x-java-applet"
    > archive="YYYYY.jar"
    > width = "500"
    > height = "300" >
    > </object>


    Unfortunately, that won't work with IE, though it will with Opera. After
    some experimentation, I found

    <object type="application/x-java-applet" width="300" height="100">
    <!--[if IE]>
    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="300" height="100">
    <![endif]-->

    <param name="code" value="XXX.class">

    Alternative content

    <!--[if IE]>
    </object>
    <![endif]-->
    </object>

    to work with IE, Opera, and Mozilla[1], avoid repeating PARAM elements,
    and allow you to specify alternative content without IE rendering it. I
    don't have access to Macs. If you can manage to compile an applet to work
    with NN4 (I can't get my compiler to regress that far :D), adding

    classid="java:XXX.class"

    to the outer OBJECT element will add further compatibility, though it
    means you're specifying the source in more than one place. If you want to
    add additional information, such as the archive attribute, you might want
    to investigate the URL I cited earlier. Some of the information might need
    to be specified in PARAM elements. I've haven't tried that.

    Perhaps someone else can suggest something simpler.

    [snip]

    Good luck,
    Mike


    [1] Includes Firefox, Mozilla, and Netscape.

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
     
    Michael Winter, Dec 22, 2004
    #2
    1. Advertising

  3. Christopher J. Henrich

    Toby Inkster Guest

    Christopher J. Henrich wrote:

    > I welcome criticism, and information on whether this markup is OK for
    > Windows browsers.


    You might get more replies by posting the URL to an example.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Dec 22, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Amil
    Replies:
    1
    Views:
    2,437
    Ken Cox [Microsoft MVP]
    Dec 12, 2003
  2. Archana
    Replies:
    1
    Views:
    1,385
    Andrew Thompson
    Oct 25, 2004
  3. Tim Streater
    Replies:
    4
    Views:
    325
    Gus Richter
    Feb 13, 2013
  4. Lewis
    Replies:
    0
    Views:
    268
    Lewis
    Feb 12, 2013
  5. Gus Richter
    Replies:
    0
    Views:
    286
    Gus Richter
    Feb 13, 2013
Loading...

Share This Page