Is this possible?

J

Jimmy

I was wondering if it's possible to have a function add an image to
the body of a page without opening a new page (ie. what happens when
you use document.write('<img src="blah">'); ). I know how to make the
function swap one pic for another, but I want to know if it's possible
to add a completely new pic. Or anything for that matter... text,
horizontal rules... Thanks for the help.

Jimmy
 
H

Hywel Jenkins

I was wondering if it's possible to have a function add an image to
the body of a page without opening a new page (ie. what happens when
you use document.write('<img src="blah">'); ). I know how to make the
function swap one pic for another, but I want to know if it's possible
to add a completely new pic. Or anything for that matter... text,
horizontal rules... Thanks for the help.
You could create a new DOM element and add the image. Never done it,
don't know the code, but a quick google should yield something.
 
L

Lasse Reichstein Nielsen

Hywel Jenkins said:
You could create a new DOM element and add the image. Never done it,
don't know the code, but a quick google should yield something.

Otherwise, here is one:

var myImg = document.createElement("img");
myImg.src = "...url...";
document.body.appendChild(myImg);

/L
 

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
474,102
Messages
2,570,645
Members
47,245
Latest member
ShannonEat

Latest Threads

Top