首页 > 解决方案 > 将 CSS 添加到 iframe 的正文中

问题描述

我已将以下 css 添加到 IFrame 的主体但它不起作用,我也尝试使用 jQuery 但没有成功。

发现不能跨域添加,找到了解决方案,但是没用

这是我尝试过的代码

.cal iframe html body {
    overflow:hidden;
}

这是我尝试使用 JQUery 的代码

 $("#myiFrame").on("load", function() {
  let body = $("#myiFrame").contents().find("body");
  let css = '<style>/********* Put your styles here **********</style>';
  $(body).append(css);
});

标签: jquerycssiframe

解决方案


推荐阅读