I am probably missing something simple but it's quite annoying when everything you read doesn't work. I have images which may be duplicated many times over the course of a dynamically generated page. So the obvious thing to do is to preload it and use that one variable as the source all the time.
var searchPic;
function LoadImages() {
searchPic = new Image(100,100);
searchPic.src = "XXXX/YYYY/search.png";
// This is correct and the path is correct
}
then i set the image using
document["pic1"].src = searchPic;
or
$("#pic1").attr("src", searchPic);
however the image is never set propertly in FireBug when I query the image i get
[object HTMLImageElement]
as the src of the image
in IE I get
http://localhost:8080/work/Sandbox/jpmetrix/[object]
if anyone could help with this i'd really appreciate it
Thanks
John