【问题标题】:Remove Class within an Iframe删除 iframe 中的类
【发布时间】:2015-05-10 08:49:09
【问题描述】:

我想用 javascript 删除 iframe 中的一个类。代码在这里:

<iframe width="456" height="940" src="//invis.io/exampleabcde" frameborder="0" allowfullscreen></iframe>

一旦 html 加载,它就会显示在开发者控制台中:

<div ng-include=" '/assets/apps/share/views/powered-by/powered-by.htm' " class="ng-scope">
<!-- Hide this object for all Shopify Enterprise project shares. ( companyID 71 ).  Everyone else should see it. -->
<div ng-controller="poweredBy.poweredByController" ng mouseenter="announceActivityChange(true)" ng-mouseleave="announceActivityChange(false)" ng-hide="project.companyID == 71" class="ng-scope">
<!-- BEGIN: Powered By Tag -->
<!-- ngIf: ! project.isMobile || share.isEmbed --><a ng-if=" ! project.isMobile || share.isEmbed " class="powered-by ng-scope active" ng-class="{ 'active': isActive }" href="http://www.invisionapp.com/?utm_medium=virality&amp;utm_source=Share%20CTA" target="_blank">
<img src="/assets/apps/share/img/logo-icon.png">
</a><!-- end ngIf: ! project.isMobile || share.isEmbed -->
<!-- END: Powered By Tag -->
</div>
</div>

我上面列出的实际代码并不是那么重要,关键是 iframe 加载了一些 angularjs,我无法访问我想要的特定类并将其删除。

当我在开发者控制台中删除代码行 class="powered-by ng-scope active" 时,它会完美地删除我想要的内容。但是我似乎无法执行代码以在 javascript 中删除此类。我尝试了$(".powered-by").remove(); 和其他几种方法,但都无法删除此类。

对于删除 iframe 类的任何帮助将不胜感激。谢谢。

`

【问题讨论】:

标签: javascript jquery html angularjs iframe


【解决方案1】:

如果 iframe 与您的页面不在同一个域中,您将无法访问 iframe 的内容,因为the same-origin policy

【讨论】:

  • 该死!真可惜;'(
猜你喜欢
  • 1970-01-01
  • 2021-10-15
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
  • 2016-02-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-09
相关资源
最近更新 更多