views:

209

answers:

1

I'm developing a Yahoo Widget. Using Javascript I'm attempting to append an image to the current viewing window. The image is not displaying. Interestingly enough i added a few alert statements to show my variables and check my work and realized that the image is actually popping up, and then dissapeearing. Does anyone know what I'm doing wrong?

Here is a snippet of my code:

var mainEle = widget.getElementById("mainWindow");
  alert(mainEle.id);
  var hOffSet = 40;
  var hOffSetBg = 20;
  var vOffSetHome = 100;
  var vOffSetAway = 130;
  var vOffSetBg = 80;

  var bgEle = new Image();
  bgEle.src = "Resources/gamelinkbg.png";
  bgEle.hOffset = hOffSetBg;
  bgEle.vOffset = vOffSetBg;
  bgEle.opacity = 255;
  bgEle.id = "newImage";

  mainEle.appendChild(bgEle);
  alert(document.getElementById("newImage").id);
A: 

bgEle is an image object, not a dom object. I think if you want to go this route you need to use createElement

Josh