我正在尝试这样:
$(document).ready(function(){
$('#muestraMotor').bind('mousedown',function(){
var cssLink = document.createElement("link");
cssLink.href = "../estilo/css/datepicker.css"; cssLink .rel = "stylesheet";
cssLink .type = "text/css";
frames['cboxIframe'].document.body.appendChild(cssLink);
});
})
其中 cboxIframe 是 iframe 的 id,
Firebug 跳跃:
frames.cboxIframe is undefined
[Detener en este error] frames['cboxIframe'].document.body.appendChild(cssLink);
-编辑-
我现在这样试试
$(document).ready(function(){
$('#txtRsvButtonGold').bind('mousedown',function(){
var $head = $("iframe#cboxIframe").contents().find("head");
$head.append($("<link/>", { rel: "stylesheet", href: "http://sameDomain.com/css/datePicker.css", type: "text/css" }));
});
});
没有错误,但我看不到带有 Firebug 的 .css 文件(并且没有应用 corse 样式)
最佳答案
您需要传递框架的 name
属性(或其在页面上的数字索引),而不是将 id
传递给 frames
关于javascript - 将 .css 文件附加到 iframe,以便可以覆盖样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8299766/