【发布时间】:2018-01-17 14:27:23
【问题描述】:
我使用 iframe 进行这样的一些计算。
<iframe id="iframe1" src="https://www.investwell.in/updation/parameter/Calculator/par_retirement_calculatorN.jsp?obgl=eeeeee&fs=14&ol=222222&obgr=dddddddd&or=111111&share=N" width="100%" height="900" frameborder="0" scrolling="auto"></iframe>
现在,我想使用 Javascript 将 css 应用到 iframe 内容,但我无法做到这一点。
JS:
$('iframe').load( function() {
$('iframe').contents().find("head")
.append($("<style type='text/css'> .panel-body{background: red !important;} </style>"));#000000';
});
谁能告诉我这里哪里出错了? 任何帮助将不胜感激。
提前致谢。
【问题讨论】:
-
iframe 内容来自外部域,因此您无法通过 JS 更改其任何内容(CSS 或其他)。
标签: javascript jquery html css iframe