开发者

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="ba开发者_开发问答ckground-image: url("http://www.domain.de/image.gif";);">


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); 


You're really thing to set the background image of an img element? That seems...odd. Are you sure you don't just want to do a normal img element (Sarfraz may have you covered there if so) or specify the background image of the wrapper element? E.g.:

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

I've marked this CW because I've never done any FBJS, so could be talking through my hat. :-) If it helps, it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜