Javascript and firefox

P

Phil

Hi,

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

The object i am trying to embed is:

<embed type="application/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.createElement("embed");
embedObj.setAttribute('type' ,'application/x-Immersion-Web-Plugin');
embedObj.setAttribute('name' ,'ImmWeb');
embedObj.setAttribute('hidden','true');

var body = document.getElementsByTagName("body")[0];
body.insertBefore(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
 
M

Martin Honnen

Phil wrote:

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

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

var body = document.getElementsByTagName("body")[0];
body.insertBefore(embedObj, body.firstChild);

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

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

Phil

Martin said:
Phil wrote:

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

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

var body = document.getElementsByTagName("body")[0];
body.insertBefore(embedObj, body.firstChild);

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

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

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

Thanks
 
M

Martin Honnen

Phil wrote:

can no


completely.


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

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

function callPlugin () {
if (document.embeds && document.embeds.ImmWeb &&
document.embeds.ImmWeb.MakeConstant) {
document.embeds.ImmWeb.MakeConstant("MyConstant");
}
else {
setTimeout('callPlugin();', 100);
}
}

...
body.insertBefore(embedObj, body.firstChild);
var tid = setTimeout('callPlugin();', 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top