Search code examples
javascriptfbmlfbjs

FBJS setStyle( {backgroundImage}) not working?



i am trying to add some images to my facebook tab-app via FBJS.

The Problem:
I can't see the images and I don't know why.

The FBJS code

url = "http://www.domain.de/image.gif";
myImg = document.createElement('img');
myImg.setStyle( {backgroundImage: 'url('+url+')' });
document.getElementById('wrapper').appendChild(myImg); 

The rendered html

<img style="background-image: url("http://www.domain.de/image.gif";);">

Solution

  • Try modifying your code like this and specify the src attribute of the image:

    url = "http://www.domain.de/image.gif";
    myImg = document.createElement('img');
    myImg.setSrc(url);
    document.getElementById('wrapper').appendChild(myImg);