删除Iframe中的类

时间:2015-03-09 08:40:20

标签: javascript jquery html angularjs iframe

我想用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类的帮助都将不胜感激。感谢。

`

1 个答案:

答案 0 :(得分:2)

由于the same-origin policy

,如果iframe与您的网页不在同一个域中,您将无法访问iframe的内容