Javascript and firefox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil

    Javascript and firefox

    Hi,

    I am trying to dynamically embed an object into a webpage using
    javascript.

    The object i am trying to embed is:

    <embed type="applicati on/x-Immersion-Web-Plugin" name="ImmWeb"
    hidden="true"></embed>

    Later on in the code I access

    document.ImmWeb .MakeConstant(" MyConstant");

    which works fine.

    However I want to embed the object dynamically, so I created a function
    which does the following:

    var embedObj = document.create Element("embed" );
    embedObj.setAtt ribute('type' ,'application/x-Immersion-Web-Plugin');
    embedObj.setAtt ribute('name' ,'ImmWeb');
    embedObj.setAtt ribute('hidden' ,'true');

    var body = document.getEle mentsByTagName( "body")[0];
    body.insertBefo re(embedObj, body.firstChild );

    This function is called when I load the page (onLoad). However I can no
    longer use:
    document.ImmWeb .MakeConstant(" MyConstant");

    as the javascript debugger states that this "is not a function". The
    only things I can access via document.ImmWeb are the attributes stated
    above (type, name and hidden). When the object is embedded normally
    there is a lot of other methods that can be accessed. (Note the
    application/x-Immersion-Web-Plugin is a component that has been
    installed)

    Am i missing something - is it not possible to dynamically embed
    objects? Is there some call i have to make somewhere to update
    something!

    Thanks
    Phil

  • Martin Honnen

    #2
    Re: Javascript and firefox



    Phil wrote:

    [color=blue]
    > However I want to embed the object dynamically, so I created a function
    > which does the following:
    >
    > var embedObj = document.create Element("embed" );
    > embedObj.setAtt ribute('type' ,'application/x-Immersion-Web-Plugin');
    > embedObj.setAtt ribute('name' ,'ImmWeb');
    > embedObj.setAtt ribute('hidden' ,'true');
    >
    > var body = document.getEle mentsByTagName( "body")[0];
    > body.insertBefo re(embedObj, body.firstChild );
    >
    > This function is called when I load the page (onLoad). However I can no
    > longer use:
    > document.ImmWeb .MakeConstant(" MyConstant");[/color]

    When are you trying to do that MakeConstant call, immediately after the
    insertBefore? In that case the plugin is probably not yet loaded completely.

    --

    Martin Honnen

    Comment

    • Rob B

      #3
      Re: Javascript and firefox


      Phil wrote:
      [color=blue]
      > Hi,[/color]
      [color=blue]
      > I am trying to dynamically embed an object into a webpage using
      > javascript.[/color]
      [color=blue]
      > The object i am trying to embed is:[/color]
      [color=blue]
      > <embed type="applicati on/x-Immersion-Web-Plugin" name="ImmWeb"
      > hidden="true"></embed>[/color]
      [color=blue]
      > Later on in the code I access[/color]
      [color=blue]
      > document.ImmWeb .MakeConstant(" MyConstant");[/color]
      [color=blue]
      > which works fine.[/color]
      [color=blue]
      > However I want to embed the object dynamically, so I created a[/color]
      function[color=blue]
      > which does the following:[/color]
      [color=blue]
      > var embedObj = document.create Element("embed" );
      > embedObj.setAtt ribute('type' ,'application/x-Immersion-Web-Plugin');
      > embedObj.setAtt ribute('name' ,'ImmWeb');
      > embedObj.setAtt ribute('hidden' ,'true');[/color]
      [color=blue]
      > var body = document.getEle mentsByTagName( "body")[0];
      > body.insertBefo re(embedObj, body.firstChild );[/color]
      [color=blue]
      > This function is called when I load the page (onLoad). However I can[/color]
      no[color=blue]
      > longer use:
      > document.ImmWeb .MakeConstant(" MyConstant");[/color]
      [color=blue]
      > as the javascript debugger states that this "is not a function". The
      > only things I can access via document.ImmWeb are the attributes stated
      > above (type, name and hidden). When the object is embedded normally
      > there is a lot of other methods that can be accessed. (Note the
      > application/x-Immersion-Web-Plugin is a component that has been
      > installed)[/color]
      [color=blue]
      > Am i missing something - is it not possible to dynamically embed
      > objects? Is there some call i have to make somewhere to update
      > something![/color]

      Any reason you're not using <object> and accessing it by id? Not
      familiar w/that plugin so, perhaps there are some issues.

      This sounds a bit like
      Internet Explorer's failure to add named references for dynamically
      created form elements to the elements[] collection. Might need to do it
      yourself:

      var body = document.getEle mentsByTagName( "body")[0];
      body.insertBefo re(embedObj, body.firstChild );
      document.ImmWeb = embedObj;

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Phil

        #4
        Re: Javascript and firefox


        Martin Honnen wrote:[color=blue]
        > Phil wrote:
        >
        >[color=green]
        > > However I want to embed the object dynamically, so I created a[/color][/color]
        function[color=blue][color=green]
        > > which does the following:
        > >
        > > var embedObj = document.create Element("embed" );
        > > embedObj.setAtt ribute('type'[/color][/color]
        ,'application/x-Immersion-Web-Plugin');[color=blue][color=green]
        > > embedObj.setAtt ribute('name' ,'ImmWeb');
        > > embedObj.setAtt ribute('hidden' ,'true');
        > >
        > > var body = document.getEle mentsByTagName( "body")[0];
        > > body.insertBefo re(embedObj, body.firstChild );
        > >
        > > This function is called when I load the page (onLoad). However I[/color][/color]
        can no[color=blue][color=green]
        > > longer use:
        > > document.ImmWeb .MakeConstant(" MyConstant");[/color]
        >
        > When are you trying to do that MakeConstant call, immediately after[/color]
        the[color=blue]
        > insertBefore? In that case the plugin is probably not yet loaded[/color]
        completely.[color=blue]
        >[/color]

        So how do u recommend waiting until the plugin is loaded - use of a
        timer?

        Thanks

        Comment

        • Martin Honnen

          #5
          Re: Javascript and firefox



          Phil wrote:

          [color=blue][color=green][color=darkred]
          >>>body.insertB efore(embedObj, body.firstChild );
          >>>
          >>>This function is called when I load the page (onLoad). However I[/color][/color]
          >
          > can no
          >[color=green][color=darkred]
          >>>longer use:
          >>>document.Imm Web.MakeConstan t("MyConstant") ;[/color]
          >>
          >>When are you trying to do that MakeConstant call, immediately after[/color]
          >
          > the
          >[color=green]
          >>insertBefor e? In that case the plugin is probably not yet loaded[/color]
          >
          > completely.
          >
          >
          > So how do u recommend waiting until the plugin is loaded - use of a
          > timer?[/color]

          Yes, you should be able to check for the method e.g.

          function callPlugin () {
          if (document.embed s && document.embeds .ImmWeb &&
          document.embeds .ImmWeb.MakeCon stant) {
          document.embeds .ImmWeb.MakeCon stant("MyConsta nt");
          }
          else {
          setTimeout('cal lPlugin();', 100);
          }
          }

          ...
          body.insertBefo re(embedObj, body.firstChild );
          var tid = setTimeout('cal lPlugin();', 100);

          Let me know whether that helps, I am not sure I have used it with
          plugins but with applets that approach has worked for me.

          --

          Martin Honnen

          Comment

          Working...