Dynamic insertion of applet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tormod Omholt-Jensen

    Dynamic insertion of applet


    I need to dynamically insert the following applet code in my document:


    <OBJECT classid="clsid: 8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 0
    HEIGHT = 0 NAME = "myApplet"
    codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version =1,3,1,3">
    <PARAM NAME = CODE VALUE = "FooApplet.clas s" >
    <PARAM NAME = CODEBASE VALUE = "http://foo.com/java/" >
    <PARAM NAME = ARCHIVE VALUE = foo.jar" >
    <PARAM NAME = NAME VALUE = "fooApplet" >
    <PARAM NAME = MAYSCRIPT VALUE = true >
    <PARAM NAME = "type" VALUE =
    "applicatio n/x-java-applet;jpi-version=1.3.1_0 3">
    <PARAM NAME = "scriptable " VALUE = "true">

    <COMMENT>
    </COMMENT>
    </OBJECT>


    The code above works fine in IE6/XP. For dyn. insertion, I try the
    code below, but it does not load the applet properly. Any ideas?


    <SCRIPT language="JavaS cript">

    var obj = document.create Element("object ");
    obj.setAttribut e("classid", "clsid:8AD9 C840-044E-11D1-B3E9-00805F499D93");
    obj.setAttribut e("width", "0");
    obj.setAttribut e("height", "0");
    obj.setAttribut e("name", "myApplet") ;
    obj.setAttribut e("id", "myApplet") ;
    obj.setAttribut e("codebase",
    "http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version =1,3,1,3");

    var p1 = document.create Element("param" );
    p1.setAttribute ("name", "code");
    p1.setAttribute ("value", "FooApplet.clas s");
    obj.appendChild (p1);

    var p2 = document.create Element("param" );
    p2.setAttribute ("name", "codebase") ;
    p2.setAttribute ("value", "http://foo.com/java/");
    obj.appendChild (p2);

    var p3 = document.create Element("param" );
    p3.setAttribute ("name", "archive");
    p3.setAttribute ("value", "foo.jar");
    obj.appendChild (p3);

    var p4 = document.create Element("param" );
    p4.setAttribute ("name", "name");
    p4.setAttribute ("value", "fooApplet" );
    obj.appendChild (p4);

    var p5 = document.create Element("param" );
    p5.setAttribute ("name", "mayscript" );
    p4.setAttribute ("value", "true");
    obj.appendChild (p5);

    var p6 = document.create Element("param" );
    p6.setAttribute ("name", "scriptable ");
    p4.setAttribute ("value", "true");
    obj.appendChild (p6);

    var p7 = document.create Element("param" );
    p7.setAttribute ("name", "type");
    p4.setAttribute ("value",
    "applicatio n/x-java-applet;jpi-version=1.3.1_0 3");
    obj.appendChild (p7);

    document.body.a ppendChild(obj) ;

    </SCRIPT>

  • W d'Anjos

    #2
    Re: Dynamic insertion of applet

    Try to use simple document.writel n's as follows:

    <SCRIPT language=JavaSc ript>
    document.writel n('<OBJECT classid="clsid: 8AD9C840-044E-11D1-B3E9-00805F499D93"') ;
    document.writel n('WIDTH = 0 HEIGHT = 0 NAME = "myApplet"' );
    document.writel n(...
    document.writel n('</OBJECT>');
    </SCRIPT>

    I hope this helps.

    Wagner

    Tormod Omholt-Jensen <toj@pvv.org> wrote in message news:<Pine.BSF. 4.56.0310021132 490.27565@verde n.pvv.ntnu.no>. ..[color=blue]
    > I need to dynamically insert the following applet code in my document:
    >
    >
    > <OBJECT classid="clsid: 8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 0
    > HEIGHT = 0 NAME = "myApplet"
    > codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version =1,3,1,3">
    > <PARAM NAME = CODE VALUE = "FooApplet.clas s" >
    > <PARAM NAME = CODEBASE VALUE = "http://foo.com/java/" >
    > <PARAM NAME = ARCHIVE VALUE = foo.jar" >
    > <PARAM NAME = NAME VALUE = "fooApplet" >
    > <PARAM NAME = MAYSCRIPT VALUE = true >
    > <PARAM NAME = "type" VALUE =
    > "applicatio n/x-java-applet;jpi-version=1.3.1_0 3">
    > <PARAM NAME = "scriptable " VALUE = "true">
    >
    > <COMMENT>
    > </COMMENT>
    > </OBJECT>
    >
    >
    > The code above works fine in IE6/XP. For dyn. insertion, I try the
    > code below, but it does not load the applet properly. Any ideas?
    >
    >
    > <SCRIPT language="JavaS cript">
    >
    > var obj = document.create Element("object ");
    > obj.setAttribut e("classid", "clsid:8AD9 C840-044E-11D1-B3E9-00805F499D93");
    > obj.setAttribut e("width", "0");
    > obj.setAttribut e("height", "0");
    > obj.setAttribut e("name", "myApplet") ;
    > obj.setAttribut e("id", "myApplet") ;
    > obj.setAttribut e("codebase",
    > "http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version =1,3,1,3");
    >
    > var p1 = document.create Element("param" );
    > p1.setAttribute ("name", "code");
    > p1.setAttribute ("value", "FooApplet.clas s");
    > obj.appendChild (p1);
    >
    > var p2 = document.create Element("param" );
    > p2.setAttribute ("name", "codebase") ;
    > p2.setAttribute ("value", "http://foo.com/java/");
    > obj.appendChild (p2);
    >
    > var p3 = document.create Element("param" );
    > p3.setAttribute ("name", "archive");
    > p3.setAttribute ("value", "foo.jar");
    > obj.appendChild (p3);
    >
    > var p4 = document.create Element("param" );
    > p4.setAttribute ("name", "name");
    > p4.setAttribute ("value", "fooApplet" );
    > obj.appendChild (p4);
    >
    > var p5 = document.create Element("param" );
    > p5.setAttribute ("name", "mayscript" );
    > p4.setAttribute ("value", "true");
    > obj.appendChild (p5);
    >
    > var p6 = document.create Element("param" );
    > p6.setAttribute ("name", "scriptable ");
    > p4.setAttribute ("value", "true");
    > obj.appendChild (p6);
    >
    > var p7 = document.create Element("param" );
    > p7.setAttribute ("name", "type");
    > p4.setAttribute ("value",
    > "applicatio n/x-java-applet;jpi-version=1.3.1_0 3");
    > obj.appendChild (p7);
    >
    > document.body.a ppendChild(obj) ;
    >
    > </SCRIPT>[/color]

    Comment

    • Tormod Omholt-Jensen

      #3
      Re: Dynamic insertion of applet


      Thanks for the suggestion. This works if the script is run before the
      onload event is trigged. I need however to insert the applet _after_ the
      onload event. Using document.write at this stage clears all the already
      displayed content of the browser.

      Tormod


      On Thu, 2 Oct 2003, W d'Anjos wrote:

      |Try to use simple document.writel n's as follows:
      |
      |<SCRIPT language=JavaSc ript>
      |document.write ln('<OBJECT classid="clsid: 8AD9C840-044E-11D1-B3E9-00805F499D93"') ;
      |document.write ln('WIDTH = 0 HEIGHT = 0 NAME = "myApplet"' );
      |document.write ln(...
      |document.write ln('</OBJECT>');
      |</SCRIPT>
      |
      |I hope this helps.
      |
      |Wagner
      |
      |Tormod Omholt-Jensen <toj@pvv.org> wrote in message news:<Pine.BSF. 4.56.0310021132 490.27565@verde n.pvv.ntnu.no>. ..
      |> I need to dynamically insert the following applet code in my document:
      |>
      |>
      |> <OBJECT classid="clsid: 8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 0
      |> HEIGHT = 0 NAME = "myApplet"
      |> codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version =1,3,1,3">
      |> <PARAM NAME = CODE VALUE = "FooApplet.clas s" >
      |> <PARAM NAME = CODEBASE VALUE = "http://foo.com/java/" >
      |> <PARAM NAME = ARCHIVE VALUE = foo.jar" >
      |> <PARAM NAME = NAME VALUE = "fooApplet" >
      |> <PARAM NAME = MAYSCRIPT VALUE = true >
      |> <PARAM NAME = "type" VALUE =
      |> "applicatio n/x-java-applet;jpi-version=1.3.1_0 3">
      |> <PARAM NAME = "scriptable " VALUE = "true">
      |>
      |> <COMMENT>
      |> </COMMENT>
      |> </OBJECT>
      |>
      |>
      |> The code above works fine in IE6/XP. For dyn. insertion, I try the
      |> code below, but it does not load the applet properly. Any ideas?
      |>
      |>
      |> <SCRIPT language="JavaS cript">
      |>
      |> var obj = document.create Element("object ");
      |> obj.setAttribut e("classid", "clsid:8AD9 C840-044E-11D1-B3E9-00805F499D93");
      |> obj.setAttribut e("width", "0");
      |> obj.setAttribut e("height", "0");
      |> obj.setAttribut e("name", "myApplet") ;
      |> obj.setAttribut e("id", "myApplet") ;
      |> obj.setAttribut e("codebase",
      |> "http://java.sun.com/products/plugin/autodl/jinstall-1_3_1_03-win.cab#Version =1,3,1,3");
      |>
      |> var p1 = document.create Element("param" );
      |> p1.setAttribute ("name", "code");
      |> p1.setAttribute ("value", "FooApplet.clas s");
      |> obj.appendChild (p1);
      |>
      |> var p2 = document.create Element("param" );
      |> p2.setAttribute ("name", "codebase") ;
      |> p2.setAttribute ("value", "http://foo.com/java/");
      |> obj.appendChild (p2);
      |>
      |> var p3 = document.create Element("param" );
      |> p3.setAttribute ("name", "archive");
      |> p3.setAttribute ("value", "foo.jar");
      |> obj.appendChild (p3);
      |>
      |> var p4 = document.create Element("param" );
      |> p4.setAttribute ("name", "name");
      |> p4.setAttribute ("value", "fooApplet" );
      |> obj.appendChild (p4);
      |>
      |> var p5 = document.create Element("param" );
      |> p5.setAttribute ("name", "mayscript" );
      |> p4.setAttribute ("value", "true");
      |> obj.appendChild (p5);
      |>
      |> var p6 = document.create Element("param" );
      |> p6.setAttribute ("name", "scriptable ");
      |> p4.setAttribute ("value", "true");
      |> obj.appendChild (p6);
      |>
      |> var p7 = document.create Element("param" );
      |> p7.setAttribute ("name", "type");
      |> p4.setAttribute ("value",
      |> "applicatio n/x-java-applet;jpi-version=1.3.1_0 3");
      |> obj.appendChild (p7);
      |>
      |> document.body.a ppendChild(obj) ;
      |>
      |> </SCRIPT>
      |

      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Dynamic insertion of applet

        Tormod Omholt-Jensen <toj@pvv.org> writes:
        [color=blue]
        > Using document.write at this stage clears all the already displayed
        > content of the browser.[/color]

        Yep.
        Please trim your quotes instead of including the enitre message you
        reply to (and it doesn't help that the one you reply to did the same).

        Anyway:[color=blue]
        > |> var p5 = document.create Element("param" );
        > |> p5.setAttribute ("name", "mayscript" );
        > |> p4.setAttribute ("value", "true");[/color]

        Shouldn't this be two times "p5.setAttribut ". Ditto for the two next
        params.
        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        Working...