【问题标题】:Google Chrome - Remove Class inside Iframe谷歌浏览器 - 删除 Iframe 中的类
【发布时间】:2022-01-14 02:03:48
【问题描述】:

如何在完全加载后从 iframe 中删除 class="js-action-group"?

<iframe src="https://000.maps.arcgis.com/apps/dashboards/000" style="width: 100%; height: 100%; border: 0"></iframe>

【问题讨论】:

  • iframe 是否与主页在同一个域中?否则,主页将无法访问其内容。

标签: javascript html iframe chrome-extension-manifest-v3


【解决方案1】:

您不能更改从不同域加载的 iframe 的内容。这是浏览器安全性的限制。如果你在同一个域上,你可以试试这个

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>contents demo</title>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 

<iframe src="https://000.maps.arcgis.com/apps/dashboards/000" style="width: 100%; height: 100%; border: 0" id="frameDemo"></iframe>
 
<script>
$( "#frameDemo" ).contents().find( ".js-action-group" ).remove();
</script>
 
</body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-06
    • 2013-09-09
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 2012-04-18
    • 1970-01-01
    • 2012-03-23
    相关资源
    最近更新 更多