简体   繁体   English

FBJS setStyle({backgroundImage})不起作用?

[英]FBJS setStyle( {backgroundImage}) not working?


i am trying to add some images to my facebook tab-app via FBJS. 我正在尝试通过FBJS将一些图像添加到我的facebook选项卡中。

The Problem: 问题:
I can't see the images and I don't know why. 我看不到图像,也不知道为什么。

The FBJS code FBJS代码

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

The rendered html 呈现的html

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

Try modifying your code like this and specify the src attribute of the image: 尝试像这样修改您的代码并指定图像的src属性:

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? 您真的是要设置img元素的背景图片吗? 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? 您确定不只是要做一个普通的img元素(如果这样,Sarfraz可能会覆盖在那里)还是指定wrapper元素的背景图片? Eg: 例如:

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. 我将其标记为CW,因为我从未做过任何FBJS,因此可以戴着帽子讲话。 :-) If it helps, it helps. :-)如果有帮助,它会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM