简体   繁体   English

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

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

I set the default body background of site to: body {background-color: red;} 我将网站的默认正文背景设置为:body {background-color:red;}

However, I am using external text input box that is displayed via an iframe and its also showing a red background. 但是,我使用的是通过iframe显示的外部文本输入框,它也显示红色背景。

How can I keep the red background for the site but change the background inside the iframe to white? 如何保持网站的红色背景,但将iframe中的背景更改为白色?

I tried doing something like, but it had no affect: 我尝试做类似的事情,但是没有影响:

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

Here is a screenshot of where the body is used: http://screencast.com/t/D2x5dFRCE 这是使用主体的屏幕截图: http : //screencast.com/t/D2x5dFRCE

Thanks! 谢谢!

Maybe it's not possible. 也许不可能。

If you are the owner of domain in the iframe, you can allow scross site scripting by a .htaccess. 如果您是iframe中域的所有者,则可以允许通过.htaccess进行跨站点脚本编写。

If you are create a project like "editor", you can use this to edit iframe elements format: 如果您要创建“编辑器”之类的项目,则可以使用它来编辑iframe元素格式:

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

Have you tried to force it using jquery? 您是否尝试过使用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