繁体   English   中英

如何更改iframe中的正文CSS元素?

[英]How to change body css elements inside iframe?

我将网站的默认正文背景设置为:body {background-color:red;}

但是,我使用的是通过iframe显示的外部文本输入框,它也显示红色背景。

如何保持网站的红色背景,但将iframe中的背景更改为白色?

我尝试做类似的事情,但是没有影响:

iframe body {background-color: white !important;}
document body {background-color: white !important;}
td body {background-color: white !important;}
tr body {background-color: white !important;}

这是使用主体的屏幕截图: http : //screencast.com/t/D2x5dFRCE

谢谢!

也许不可能。

如果您是iframe中域的所有者,则可以允许通过.htaccess进行跨站点脚本编写。

如果您要创建“编辑器”之类的项目,则可以使用它来编辑iframe元素格式:

$("#iframName").contents().find(element)

您是否尝试过使用jquery强制使用它?

$("#iFrame").contents().find("#someDiv").css({width:'450px'});
$("#iFrame").contents().find("body").css({color:'red'});

暂无
暂无

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

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