PDA

View Full Version : Dealing with dynamic images



LottaLava
Mar 25th, 2003, 02:21 PM
Hello folks, im wondering how is the best way to create a dynamic image, could anyone tell me?

Ive just tried this, but it didnt work out.

function onLoad_init( )
{
var img = document.createElement( "img" );

img.src = "./grandfather_clock.gif";

document.appendChild( img );
}

Any hint?

Regards,
LottaLava:D

Weirdan
Mar 25th, 2003, 05:19 PM
document hasn't method named "appendChild".
use named div instead:


function onLoad_init( )
{
var img = document.createElement( "img" );
img.src = "http://test12.cardsgate.com/1/image/cg_logo.jpg";
name_of_the_div.appendChild( img );
}
....
<div id='name_of_the_div'></div>

cheesebagpipe
Mar 25th, 2003, 10:25 PM
function onLoad_init( )
{
var an_img = document.createElement( "img" );

an_img.setAttribute("src" , "http://www.mysite.com/images/grandfather_clock.gif");

document.body.appendChild( an_img );
}