2010-03-22 92 views
0

我试图删除通过lightbox效果中的iframe加载的页面上的背景图像。我已经验证了body是被选中的iframe中的正确元素,但我无法让背景图片消失。我错过了明显的东西吗?JQuery从iframe中删除背景

var body = jQuery('#fancybox-frame').contents().find('body'); 

body.css({ 
'background': 'none', 
'background-image': 'none', 
'background-color': '#fff' 
}); 

UPDATE:目前我该元素的CSS读取(根据萤火虫)...

body { 
    background-color:#5A7E92; 
    background-image:url("/images/background.gif"); 
    border:10px solid #021E2F; 
    font-family:verdana,san-serif; 
    font-size:10pt; 
    margin:auto; 
} 

UPDATE:您可以通过点击 “邮件” 看到这里的例子链接... http://www.retailcustomerexperience.com/article/21532/GlobalShop-DOOH-measurement-essential-for-reaching-customers

+0

你要加载什么页面? – SLaks 2010-03-22 13:09:27

+0

框架页面是否与父页面在同一个域上? – 2010-03-22 13:12:06

+0

是的,他们在同一个域。 – Webnet 2010-03-22 13:19:38

回答

0

背景可能是在一些其他元素。

检查Firebug中的页面,并检查哪个元素具有背景。

+0

证实,它是在身体元素。 – Webnet 2010-03-22 13:25:11

0

我认为如果你让这些值为空,它实际上不会做你期待的。尝试设置背景以“继承”并查看它的功能。

+0

试过了,没有效果。 – Webnet 2010-03-22 13:13:20

0

尝试更改background-imagenone。这是该CSS属性的有效值,我相信会明确删除您的背景图片。

+0

我也试过,没有结果。 – Webnet 2010-03-22 13:24:50

0

这可能不是完整的答案,但这可能会帮助您找到答案。

<iframe frameborder="0" style="width:756px;height:439px;background-image:none;background-color:transparent" src="http://janemonheitonline.com/photos?KeepThis=true&amp;" hspace="0" allowtransparency="true"> </iframe> 

Internet Explorer需要“allowtransparency”才能删除iframe上的背景图像和背景颜色。试试这个代码,看看背景图片是否在iframe而不是body上。

通过点击任何主导航链接,您可以看到代码如何工作在http://janemonheitonline.com