+3 william appiah-dankwah · February 15, 2015
i want to place an image in javascript how do you do that? does anyone know? 

Post a Reply


- page 2
Oldest  Newest  Rating
0 william appiah-dankwah · March 20, 2015
@michal walker na never worked there's another way though
0 william appiah-dankwah · March 20, 2015

Var image = new image;

image.src = "pic/image.jpeg";


0 michael walker · March 20, 2015
nah it does work it should be

"Var image = new image; "

should be " var image = new Image" - that Image next to new has to start with a capital i.

//My code tested on Dreamweaver CS6 and fully works

var image = new Image;
var image2 = new Image;
0 michael walker · March 20, 2015
now it does work i see the problem in your code:

the code is:
var x = new Image; - the word "Image" next to new must be with a capital letter 

x.src="(your path)";


I have tested the code with numerous uploads of images on Dreamweaver CS6 and it works.

i hope this helps :)
0 william appiah-dankwah · March 20, 2015
:'( yeah thanks walker, man. why append child though?
0 william appiah-dankwah · March 21, 2015
:'( the variable only works if you call it image why?
0 william appiah-dankwah · March 21, 2015
well i had been looking at that code till early hours in the morning re writing the code and checking for mistakes. i find that strange the mistakes have been found this morning :ermm::ermm: 
0 william appiah-dankwah · March 21, 2015
Trying to work out append child i understand its the last child node but i just want to clarify this in this code.:'(:(

function Yellow(){

// the Parent node is image

var image = new Image;

//the last child is image.src and thats what is being appended in this code

image.src = "pic/photo-1.JPG";


is that correct? :ninja:

0 michael walker · March 23, 2015
Yes that is my understanding of it as well :) sorry weekend super busy XD
0 william appiah-dankwah · April 14, 2015
worked the append child out need to re-read how do you use pop(); to remove image thats what i am working on right now



A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.