How do I create an Image for ANOTHER document?

B

Bani

The following code works fine if it is executed in the same window
where "node" belongs. But if node belongs to a document in another
window (popup), then I get an error because the created image belogs to
the wrong document:

img = new Image();
img.src = "image.gif";
node.appendChild(img);


My question: How can I specify the document where an image belongs?
 
M

michael elias

You have to create a new image element;

var img = document.createElement('IMG');
img.src = "image.gif";
node.appendChild(img);

The document object must be the one to which the new element will be
added.
 

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,796
Messages
2,569,645
Members
45,364
Latest member
CrypttoTaxSofttware

Latest Threads

Top