0
votes

For example, a embed node like this:

document.createElement('embed');
ctrlEmbed.setAttribute('id', moduleid);
ctrlEmbed.setAttribute('src', 'xx.nmf');
ctrlEmbed.setAttribute('type', 'application/x-pnacl');
node.addEventListener('load', moduleDidLoad, true);

And the moduleDidLoad Function is:

function moduleDidLoad()
{
    ctrlMoudle = document.getElementById(moduleid);
}

As the Native Client develop guide say,If you want get the handle of native client module,you must call document.getElementById(moduleid) in the callback function of 'load' event. My question is, can i just call document.getElementById(moduleid) after i create the element?I've tried but failed.Do i have to call document.getElementById(moduleid) after the is loaded?

1

1 Answers

2
votes

document.getElementById can't locate an item in the document unless it's already been added into the document (document.body.appendChild etc). createElement creates an unattached DOM object.

This behavior is independent of NaCl.