is the image in a folder that is in a folder where the script is.
say you have a folder set up like this
Code
Sitefolder>
pages>
images>
(random.png)
scripts>
(random.js)
styles>
In which case
Code
avatarImage.src = "img/avatar.png";
alert(avatarImage.width);
should be
Code
avatarImage.src = "../img/avatar.png";
alert(avatarImage.width);
but instead its reading it as
Code
Sitefolder>
pages>
scripts>
(random.js)
images>
(random.png)
styles>
The "../" is telling the script to take a step back and then go in to images instead of going in to a folder called images where ever your script is.
Edit:
that the simplest way to do it, otherwise you can just type the whole location like "C:/mycomputer/soandso/soandso/images/random.png"
This post was edited by PumperNickle on Feb 1 2014 11:14pm