Applet launched from a Web base formular

Discussion in 'Java' started by Maldo, Feb 27, 2006.

  1. Maldo

    Maldo Guest

    Hi every body

    I'm coding a small applet wich specific function must be executed from a Web
    base formular (HTML & Javascript code)
    I'm using JRE 1.5 & the following HTML code:

    <html>
    <head>
    <title>Test </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#E9D8C8">
    <h1> AppletTest </h1>

    <DIV id="dvObjectHolder">Applet comes here</DIV>
    <br><br>

    <script language="JavaScript">
    var _info = navigator.userAgent;
    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)
    || (_info.indexOf("Linux") > 0)));
    var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
    var _ie = (_info.indexOf("MSIE") > 0
    && _info.indexOf("Win") > 0
    && _info.indexOf("Windows 3.1") < 0);
    </script>
    <script language="JavaScript">
    function testit() {
    document.getElementById('lblOutputText').innerHTML =
    document.appletTest1.test();
    }

    if (_ie == true)
    document.writeln('<OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" name="appletTest1"
    width="100" height="50"> <PARAM name="code" value="Test.class"> <PARAM
    NAME="archive" VALUE="applet.jar"> </OBJECT>');
    else if (_ns == true && _ns6)
    document.writeln('<EMBED code="Test.class" name="appletTest1"
    width="100" height="50" type="application/x-java-applet;version=1.5"
    ARCHIVE="applet.jar"
    pluginspage="http://java.sun.com/j2se/1.5.0/download.html"></EMBED>');
    </script>

    <label id="lblOutputText">This text will be replaced by the applet</label>
    <br><br>
    <input value="Click" type=button onClick="testit()"><br>


    </body>
    </html>


    I'm running this script under the following navigators:
    - Internet Explorer v6.0
    - Firefox v1.5

    The Test class has 2 functions init() & test().
    test() only returns a "Hello World" string.
    init() Applet default function launch test(), When the web page & the applet
    are loaded, I have the "Hello World" string displayed in the HTML label.
    But when I click on the "Click" button i get a Javascript error on Firefox
    (ans IE) saying that "document.appletTest1.test is not a function"

    I've already done such tricks but using JRE 1.3 ... is there something
    changed in JRE 1.4 or JRE 1.5 ??
    What i've done wrong ?

    Thanks for help :)
    Maldo, Feb 27, 2006
    #1
    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. hyena
    Replies:
    2
    Views:
    2,215
    hyena
    Jul 1, 2004
  2. Jochen Fuhrmann

    force a formular just to take numbers

    Jochen Fuhrmann, Oct 5, 2003, in forum: HTML
    Replies:
    9
    Views:
    401
  3. Clemens Richter

    HTML Formular question

    Clemens Richter, Nov 7, 2003, in forum: HTML
    Replies:
    1
    Views:
    415
    Steve Pugh
    Nov 7, 2003
  4. Wanadoo
    Replies:
    0
    Views:
    565
    Wanadoo
    Jun 18, 2006
  5. Replies:
    17
    Views:
    740
    lukas
    Jul 29, 2006
Loading...

Share This Page