images

+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

Replies

- page 1
Oldest  Newest  Rating
0 Jay Tauron · February 16, 2015
What do you mean by place? You can create an image object

I = new Image();
I.src = 'path/to/pic.jpg';
0 william appiah-dankwah · February 16, 2015
Iv never seen that code. What I mean by place is to put an image in the javascript browser 
0 william appiah-dankwah · February 16, 2015
Could you right  give me a better explanation of the code does it get used as a function or just on its own like how you have written it?
0 william appiah-dankwah · March 3, 2015
Why isn't that code working?
0 Abhinav Shukla · March 4, 2015
 You can use html code to put a image in javascript. You put it in the document.write section.
For an example
document.write("");
0 william appiah-dankwah · March 4, 2015
Not with document.write
0 william appiah-dankwah · March 4, 2015
U don't know what it's for @abhinav
0 william appiah-dankwah · March 4, 2015

function Blue(){
var Pic_on = new image(256, 189)
Pic_on.src = "image.jpg";

Document.write(Pic_on.src);

}

This just  tells you were that image is when you use document.write();

document.write(); is just used for testing
i want the image to display









0 william appiah-dankwah · March 17, 2015
do you literally have to put in the path to pic?
0 michael walker · March 20, 2015
Here bro: 

<script type="text/javascript"> 
//this creates the variable
var image = new Image;
 //this is where you get the image note Images/tut.jpg is my path to image.
image.src = "Images/tut.jpg"; - you must place your own path to point to the image
//code that adds it to your webpage
document.body.appendChild(image);

</script>

Javascript

107,253 followers
About

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

Links
Moderators